public static void main(String args[]) {
final Frame frmFrame = new Frame(); Panel pnlPanel = new Panel();
Label lblUsername = new Label(\"用户名\"); Label lblPassword = new Label(\"密码\");
final TextField txtUsername = new TextField(\"管理员\"); final TextField txtPassword = new TextField(\"\ txtUsername.setEditable(false); txtPassword.setEchoChar('*');
Button btnButton1 = new Button(\"登录\"); Button btnButton2 = new Button(\"其它用户登录\"); Button btnButton3 = new Button(\"关闭\");
btnButton1.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
if( (txtPassword.getText()).length() == 0 ) {
JOptionPane.showMessageDialog(frmFrame, \"密码不能为空\"); return; }
txtPassword.setColumns(16);
System.out.println(txtUsername.getText()+\"用户的密码:\"+ txtPassword.getText() ); }
} );
btnButton2.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
txtUsername.setEditable(true); } } );
btnButton3.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0); } } );
pnlPanel.add(lblUsername); pnlPanel.add(txtUsername); pnlPanel.add(lblPassword); pnlPanel.add(txtPassword); pnlPanel.add(btnButton1); pnlPanel.add(btnButton2); pnlPanel.add(btnButton3); frmFrame.add(pnlPanel);
frmFrame.setTitle(\"请输入密码!!\"); frmFrame.setBackground(Color.white); frmFrame.setLocation(250,250); frmFrame.pack(); frmFrame.show(); } }
因篇幅问题不能全部显示,请点此查看更多更全内容