Java Swing设置图标Icon

该方法就是设置图标方法 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();

    }

 

全部评论

相关推荐

请hr大人把offe...:你这帖子发的左右脑互搏吗兄弟
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务