Java Swing设置图标Icon

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_40990854/article/details/84315215

该方法就是设置图标方法 setIconImage()

public class Login extends JFrame{
    private JLabel nameLabel = new JLabel("登录名:");
    private JLabel passwordLabel = new JLabel("密码:");
    private JTextField nameTextField = new JTextField();
    private JPasswordField passwordPasswordField = new JPasswordField();
    private JButton btnLogin = new JButton("登录");
    private JButton btnCancle = new JButton("取消");

    private Master master = new Master();

    public Login(){
        this.setTitle("宠物管理系统");
        this.setSize(500,500);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.getContentPane().setBackground(new Color(255, 255, 255));
        // 这一条就是
        this.setIconImage(new ImageIcon("src/cn/jbit/epet/image/dog.jpg").getImage());
        this.
        init();

    }

猜你喜欢

转载自blog.csdn.net/qq_40990854/article/details/84315215