public class LoginFrame extends JFrame{
private JLabel nameLable ;
private JLabel passLable ;
private JButton loginBut ;
private JButton exieBut ;
private JTextField inputUser ;
private JPasswordField inputPass;
public LoginFrame(){
super("大桥汽修厂管理程序") ;
this.setLayout(null) ;
this.setLocation(ScreenSize.getScreenWidth(),ScreenSize.getScreenHeight()) ;
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
this.setSize(300,300) ;
this.setVisible(true) ;
this.setResizable(false) ;
this.nameLable = new JLabel("用户名:") ;
this.nameLable.setBounds(20,20,60,20) ;
this.inputUser = new JTextField("",10) ;
this.inputUser.setBounds(100,20,120,20) ;
this.passLable = new JLabel("密 码:") ;
this.passLable.setBounds(20,80,60,20) ;
this.inputPass = new JPasswordField() ;
this.inputPass.setBounds(100,80,120,20) ;
this.add(nameLable) ;
this.add(passLable) ;
this.add(inputUser) ;
this.add(inputPass) ;
}
}
我换了两个机子,这个程序在运行的时候效果有时候会出来,有时候不会出来。但是代码改一下就好了,不知道是什么原因,有懂的说声
public class LoginFrame extends JFrame{
private JLabel nameLable ;
private JLabel passLable ;
private JButton loginBut ;
private JButton exitBut ;
private JTextField inputUser ;
private JPasswordField inputPass;
public LoginFrame(){
super("大桥汽修厂管理程序") ;
this.setLayout(null) ;
this.nameLable = new JLabel("用户名:") ;
this.nameLable.setBounds(50,50,60,20) ;
this.inputUser = new JTextField("",10) ;
this.inputUser.setBounds(130,50,120,20) ;
this.passLable = new JLabel("密 码:") ;
this.passLable.setBounds(50,80,60,20) ;
this.inputPass = new JPasswordField() ;
this.inputPass.setBounds(130,80,120,20) ;
this.loginBut = new JButton("登录") ;
this.loginBut.setBounds(60,130,60,20) ;
this.exitBut = new JButton("退出") ;
this.exitBut.setBounds(170,130,60,20) ;
this.add(nameLable) ;
this.add(passLable) ;
this.add(inputUser) ;
this.add(inputPass) ;
this.add(loginBut) ;
this.add(exitBut) ;
this.setLocation(ScreenSize.getScreenWidth(),ScreenSize.getScreenHeight()) ;
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
this.setSize(300,200) ;
this.setVisible(true) ;
this.setResizable(false) ;
}
}
|