资源预览内容
第1页 / 共9页
第2页 / 共9页
第3页 / 共9页
第4页 / 共9页
第5页 / 共9页
第6页 / 共9页
第7页 / 共9页
第8页 / 共9页
第9页 / 共9页
亲,该文档总共9页全部预览完了,如果喜欢就下载吧!
资源描述
用户登录界面的设计与实现,继承、接口综合应用实例,张凌云,2,GUI( Graphical User Interface ) 图形用户界面,WebUI,WinUI,3,本节任务,本节任务:使用java完成用户登录窗口 实验目的:熟练掌握继承与接口,4,任务分析,Frame,ActionListener,一、类。自定义登录窗口类LoginFrame,二、属性。向窗口中添加文本框与按钮,三、方法。添加按钮单击事件响应代码,5,一、类。自定义登录窗口类,class LoginFrame extends Frame /步骤1:声明继承自Frame类 public LoginFrame()/步骤2:定义构造方法this.setSize(200,200);this.setVisible(true);public static void main(String args)new LoginFrame();/步骤3:创建自定义窗口对象 ,6,二、属性。向窗口中添加文本框与按钮,private TextField text_user,text_pwd; private Button button_login; /步骤1:声明对象this.setLayout(new FlowLayout(); /设置各控件的布局方式this.add(new Label(“用户名:“); text_user = new TextField(20);/步骤2:实例化对象 this.add(text_user); /步骤3:将对象添加到窗体,7,三、方法。添加按钮单击事件响应代码,class LoginFrame extends Frame implements ActionListener/步骤1:声明实现ActionListener接口button_login.addActionListener(this);/步骤3:在构造方法中给按钮添加监听对象public void actionPerformed(ActionEvent arg0) /步骤2:实现接口方法 if(arg0.getSource() = button_login)String str_user = text_user.getText();String str_pwd = text_pwd.getText();/判断用户名及密码是否正确,弹出相应消息框。如:JOptionPane.showMessageDialog(null, “欢迎登录本系统); ,8,小结,一、类。Frame类 二、属性。TextField与Button类 三、方法。ActionListener接口,9,本节涉及到的 各组件类间的继承关系,Object,Component,Button,Lable,TextComponent,TextArea,TextField,Container,Panel,Applet,Window,Frame,
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号