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