77范文网 - 专业文章范例文档资料分享平台

java多功能选择器(3)

来源:网络收集 时间:2019-06-05 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

private String[] nameString; private String[] passwordString; private JTextField inputName;

private JPasswordField passwordField;

private ChoseFrame chose=new ChoseFrame();

private JFrame hist=new JFrame();

public static void main(String[] args){

TestPasswordField frame = new TestPasswordField(); frame.setTitle(\系统登录窗体\ frame.setLocationRelativeTo(null); frame.setSize(350,250);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }

public TestPasswordField(){ setLayout(null);

nameString = createNameString();

passwordString = createPasswordString(); JLabel name = new JLabel(\用户名:\ name.setBounds(20,60,80,40); inputName = new JTextField(10); inputName.setBounds(110,60,140,30);

inputName.setToolTipText(\名字不能超过10个字符!\ JLabel password = new JLabel(\密码:\ password.setBounds(20,110,100,30);

passwordField = new JPasswordField(8); passwordField.setEchoChar('*');

passwordField.setBounds(110,110,140,30);

passwordField.setToolTipText(\密码不能超过8个字符,且必须为数字!\

ImageIcon imageIcon =new ImageIcon(\

Image image=imageIcon.getImage(); JButton pa=new JButton(\ JButton login = new JButton(\登录\ JButton hellp= new JButton(\帮助\ JButton exit = new JButton(\退出\ pa.setBounds(0,0,340,50);

login.setBounds(15,170,100,35); hellp.setBounds(115,170,100,35); exit.setBounds(215,170,100,35); add(pa); add(name);

add(inputName); add(password);

add(passwordField); add(login); add(hellp); add(exit);

login.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ int index=0;

String text = inputName.getText(); String word = new String(passwordField.getPassword());

for(int i = 0;i < nameString.length;i++) if(text.equals(nameString[i]) ){ index = i; break; }

if(word.equals(passwordString[index])){

JOptionPane.showMessageDialog(null,\恭喜!登录成功!\

hist.setVisible(true); }

else

JOptionPane.showMessageDialog(null,\对不起,您输入的密码和姓名不匹配,请重新输入!\ } });

hellp.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){

JOptionPane.showMessageDialog(null,\用户名:huguanglin,密码:19891210\ } });

exit.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ System.exit(0); } });

inputName.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String text = inputName.getText(); Boolean bool=false;

for(int i = 0;i < nameString.length;i++ ) if(text.equals(nameString[i])) bool = true; if(bool)

JOptionPane.showMessageDialog(null,\输入合理,请继续!\ else

JOptionPane.showMessageDialog(null,\输入不合理,请重新输入!\ } });

hist.add(chose); hist.pack();

hist.setTitle(\多功能选择系统\

}

public String[] createNameString(){ String[] name = {\ \ return name; }

public String[] createPasswordString(){ String[] password = {\

\;

return password; } }

// ChoseFrame类

import java.awt.event.*; import java.awt.*; import javax.swing.*;

public class ChoseFrame extends JPanel{

private ClockAnimation still=new ClockAnimation(); // private KeyListenerDemo key=new KeyListenerDemo(); private JFrame jat=new JFrame();

private JFrame histmoon1=new JFrame(); public ChoseFrame(){ setLayout(null);

setBounds(50,50,300,300);

ImageIcon imageIcon =new ImageIcon(\ Image image=imageIcon.getImage(); JButton pa=new JButton(\ JButton login = new JButton(\显示时钟\ JButton move=new JButton(\升旗仪式\ JButton hellp=new JButton(\图片移动\

JButton explain=new JButton(\系统简介\ JButton exit = new JButton(\退出\ pa.setBounds(0,0,300,100);

login.setBounds(50,120,100,35); hellp.setBounds(50,170,100,35); explain.setBounds(150,120,100,35); move.setBounds(150,170,100,35); exit.setBounds(110,240,100,35); add(pa); add(login); add(hellp); add(move); add(explain); add(exit);

histmoon1.add(still); histmoon1.pack();

histmoon1.setTitle(\多功能选择系统\

explain.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){

String string=\VA多功能选择器\\n\一个登陆界面\一个选择界面,可以选择不同的java程序!\

JOptionPane.showMessageDialog(null,string); } });

login.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){

JOptionPane.showMessageDialog(null,\欢迎使用显示时钟!\

histmoon1.setVisible(true); } });

hellp.addActionListener(new ActionListener(){

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库java多功能选择器(3)在线全文阅读。

java多功能选择器(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/649779.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: