免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
最近在翻阅java基础知识的时候偶然间看到了jpassword的用法的介绍,然后写下了如下的这个demo,供参考,提供意见实现功能:当你输入用户名和密码后会返回一个窗体,有刚才输入的用户名和密码。代码如下所示:package ;/实现读取登录的密码和用户名import java.awt.Container;import java.awt.GridLayout;import java.awt.Label;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JOptionPane;import javax.swing.JPasswordField;import javax.swing.JTextField;public class JpasswordField extends JFrame/* param args*/JTextField userName;JPasswordField password;JButton loginBtn;JButton cancelBtn;public JpasswordField()super(Jpassword的演示);Container container=getContentPane();container.setLayout(new GridLayout(3,2);userName=new JTextField(16);password=new JPasswordField(16);loginBtn=new JButton(登录);loginBtn.addActionListener(new ActionListener()public void actionPerformed(ActionEvent evt)char pw=password.getPassword();String message=您的用户名是:+userName.getText()+n您的密码是:+new String(pw);if(message=null)System.out.println(你需要输入用户名和密码);elseJOptionPane.showMessageDialog(JpasswordField.this, message););cancelBtn=new JButton(取消);cancelBtn.addActionListener(new ActionListener()public void actionPerform(ActionEvent evt)System.exit(0);Overridepublic void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubSystem.exit(0););container.add(new Label(userName:);container.add(userName);container.add(new Label(passWord:);container.add(password);container.add(loginBtn);container.add(cancelBtn);this.setSize(300,150);this.setLocation(400, 250);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setVisible(true);public static void main(String args) new JpasswordField();最近在翻阅java基础知识的时候偶然间看到了jpassword的用法的介绍,然后写下了如下的这个demo,供参考,提供意见实现功能:当你输入用户名和密码后会返回一个窗体,有刚才输入的用户名和密码。代码如下所示:package ;/实现读取登录的密码和用户名import java.awt.Container;import java.awt.GridLayout;import java.awt.Label;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JOptionPane;import javax.swing.JPasswordField;import javax.swing.JTextField;public class JpasswordField extends JFrame/* param args*/JTextField userName;JPasswordField password;JButton loginBtn;JButton cancelBtn;public JpasswordField()super(Jpassword的演示);Container container=getContentPane();container.setLayout(new GridLayout(3,2);userName=new JTextField(16);password=new JPasswordField(16);loginBtn=new JButton(登录);loginBtn.addActionListener(new ActionListener()public void actionPerformed(ActionEvent evt)char pw=password.getPassword();String message=您的用户名是:+userName.getText()+n您的密码是:+new String(pw);if(message=null)System.out.println(你需要输入用户名和密码);elseJOptionPane.showMessageDialog(JpasswordField.this, message););cancelBtn=new JButton(取消);cancelBtn.addActionListener(new ActionListener()public void actionPerform(ActionEvent evt)System.exit(0);Overridepublic void actionPerformed(ActionEvent arg0) / TODO Auto-generated method stubSystem.exit(0););container.add(new Label(userName:);container.add(userName);container.add(new Label(passWord:);container.add(password);container.add(loginBtn);container.add(cancelBtn);this.setSize(300
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 高分子材料 课后练习 高二化学人教版(2019)选择性必修3
- 心理调适小妙招分享主题班会
- 压力变动力主题班会
- 非股东固定分红协议书模板
- 离职协议书文案范本模板
- 光伏行业敬业协议书模板
- 画室合作协议书范本模板
- 儿童节购物习惯调研
- 爽肤水销售转让合同
- 儿童模特培训教学协议
- 2024吉林省旅游控股集团所属出资企业招聘2人高频考题难、易错点模拟试题(共500题)附带答案详解
- 2024-2030年玻璃通孔(TGV)晶片行业市场现状供需分析及重点企业投资评估规划分析研究报告
- 糖尿病足溃疡创面治疗专家共识(2024)解读
- 中国高血压防治指南(2024年修订版)图文解读
- 《高等教育学》近年考试真题题库(含答案)
- 共烧陶瓷基板厂设计规范
- 与中介签建造师协议
- 普通话(完整版)课件
- 法律常识题库500题及参考答案一套
- 高考英语七选五试题真题汇编及解析
- 医学科普脱口秀康复医学科
评论
0/150
提交评论