java怎么写页面( 三 )


8.登陆界面的java代码怎么写原发布者:梦妙奇缘
用户登录的代码://LoginFrame.javaimportjavax.swing.*;importjava.awt.*;importjava.awt.event.*;classMyJPanelextendsJPanelimplementsActionListener{privateintcount=0;privateJLabellabel1,label2;privateJTextFieldtext;privateJPasswordFieldpass;privateJButtonbutton1,button2;MyJPanel(){label1=newJLabel("用户名");label2=newJLabel("密码");button1=newJButton("确定");button2=newJButton("取消");text=newJTextField(20);pass=newJPasswordField(20);button1.setMnemonic(KeyEvent.VK_O);//设置按钮快捷键button2.setMnemonic(KeyEvent.VK_C);button1.setActionCommand("entry");button2.setActionCommand("cancel");button1.addActionListener(this);//注册按钮事件button2.addActionListener(this);//注册按钮事件setBackground(Color.cyan);//设定面板背景色add(label1);add(text);add(label2);add(pass);add(button1);add(button2);}publicvoidactionPerformed(ActionEvente){if(e.getActionCommand().equals("entry")){count++;//计数Stringusername,password;if(count<3){

java怎么写页面

文章插图