该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class FrmLogin extends JFrame{
private JPanel p;
private JLabel lblName,lblpwd;
private JTexField txtName;
private JPasswordField txtpwd;
private JButton btnOk,btnCancel;
public FrmLogin(){
super("登陆");
p=new JPanel();
p.setLayout(null);
//实例化文本 按钮 文本框 密码框
lblName=new JLabel("用户名");
lblpwd=new JLabel("密 码");
txtName=new JTexField(20);
tetpwd=new JPasswordFiled(20);
txtpwd.setEchoChar('*');
btnOk=new JButton("确定");
btnCancel=new JButton("取消");
//设置控件的位置
lblName.setBounds(30,30,60,25);
txtName.setBounds(95,30,120,25);
lblpwd.setBounds(30,60,60,25);
txtpwd.steBounds(95,60,120,25);
btnOk.setBounds(30,90,60,25);
btnCancel.setBounds(125,90,60,25);
//添加到容器中
p.add(lblName);
p.add(txtName);
p.add(lblpwd);
p.add(txtpwd);
p.add(btnOk);
p.add(btnCancel);
this.add(p);
this.setSize(250,170);
this.setLocation(300,300);
//设置窗体不可改变大小
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
//运行窗口
/**
* @param args
*/
public static void main(String[] args) {
FrmLogin frmLogin=new FrmLogin;
frmLogin.setVisible(true);
// TODO Auto-generated method stub
}
}
楼主,借个地,问个问题。。
上面这个是我按书上打的,问什么运行出错啊。。。。
求大神帮我看看,修改一下