import java.awt.*;
import javax.swing.*;
public class TestFrame extends JFrame {
public static void main(String[] args){ //测试
TestFrame login = new TestFrame();
}
public TestFrame(){ //构造方法
super();
setTitle("系统登陆");
setBounds(300,200,300,175);
Container c = getContentPane();
c.setLayout(null); //取消布局管理器,使用绝对布局
JLabel user = new JLabel("用户:");
JLabel password = new JLabel("密码:");
JTextField txf_userName = new JTextField();
JPasswordField pwd_password = new JPasswordField()
{
public void paste(){
UIManager.getLookAndFeel().provideErrorFeedback(this);
}
};
JButton btn_enter = new JButton("登陆");
JButton btn_exit = new JButton("退出");
user.setBounds(50,25,50,25);
password.setBounds(50,52,50,25);
txf_userName.setBounds(100,25,150,25);
pwd_password.setBounds(100,52,150,25);
btn_enter.setBounds(50,100,75,25);
btn_exit.setBounds(175,100,75,25);
c.add(user);
c.add(txf_userName);
c.add(password);
c.add(pwd_password);
c.add(btn_enter);
c.add(btn_exit);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false); //禁止改变大小
setVisible(true); //可见
}
}
ctrl+V OK
Ctrl+C 不确定,本地环境ok
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) Client VM (build 14.1-b02, mixed mode, sharing)