用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

挂机界面

2014-05-10 作者: 云代码会员举报

[java]代码库

//挂机
package com.view;
 
import java.awt.Color;
 
/**
 * 挂机界面
 * @author Administrator
 *
 */
public class SystemHook extends JDialog implements ActionListener{
    /**
     * 成员变量
     */
    private static final long serialVersionUID = 1L;
    private JPasswordField passwordField;
    private JButton yesBut,delBut;
    private JLabel keyLab;
 
    //设置全局的锁
    private String key;//可以不全为数字
    private int status=0;//回车的当前状态0:set;1:get;
    private Menu menu;
    private JLabel alertLab;
    private JLabel img1;
     
    public int getStatus() {
        return status;
    }
 
    public void setStatus(int status) {
        this.status = status;
    }
 
    public String getKey() {
        return key;
    }
 
    public void setKey(String key) {
        this.key = key;
    }
     
    public Menu getMenu() {
        return menu;
    }
 
    public void setMenu(Menu menu) {
        this.menu = menu;
    }
//  /**
//   *new 测试
//   */
//  public static void main(String[] args) {
//      try {
//          SystemHook dialog = new SystemHook();
//          dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
//          dialog.setVisible(true);
//      } catch (Exception e) {
//          e.printStackTrace();
//      }
//  }
 
     
 
    /**
     * 构造函数初始化
     * @param b
     * @param menu
     */
    public SystemHook(Menu menu, boolean b) {
        super(menu,b);
        this.menu=menu;
        this.setTitle("系统挂机");
        setBounds(100, 100, 499, 331);
        this.setLocationRelativeTo(null);
        getContentPane().setLayout(null);
        {
            alertLab = new JLabel("<html><b><font color=white size=5 face='楷体'>系 统 修 改</font></b><br/><font color=white size=4>xi tong gua ji</font></html>");
            alertLab.setBounds(32, 31, 162, 58);
            getContentPane().add(alertLab);
             
            JLabel topImage = new JLabel("");
            topImage.setIcon(new ImageIcon("image/挂机top.jpg"));
            topImage.setBorder(new TitledBorder(""));
            topImage.setBounds(0, 0, 483, 113);
            getContentPane().add(topImage);
        }
         
        keyLab= new JLabel("设置挂机锁:",JLabel.RIGHT);
        keyLab.setBounds(61, 154, 117, 33);
        getContentPane().add(keyLab);
         
        passwordField = new JPasswordField();
        passwordField.addActionListener(this);//监听1
        passwordField.setBounds(188, 154, 193, 33);
        getContentPane().add(passwordField);
         
        yesBut= new JButton("挂机");
        yesBut.addActionListener(this);//监听1
        yesBut.setBounds(310, 250, 71, 33);
        getContentPane().add(yesBut);
         
        delBut = new JButton("取消");
        delBut.addActionListener(this);//监听1
        delBut.setBounds(402, 250, 71, 33);
        getContentPane().add(delBut);
         
        img1 = new JLabel(new ImageIcon("image/挂机ico.png"));
        img1.setText("挂机中......");
        img1.setBounds(186, 197, 125, 33);
        img1.setVisible(false);
        getContentPane().add(img1);
         
        this.setVisible(true);
    }
 
    /**
     * 注册监听器1
     */
    @Override
    public void actionPerformed(ActionEvent de) {
        // TODO Auto-generated method stub
        String type=de.getActionCommand();
        String psw=new String(passwordField.getPassword());
        if(type.equals("挂机")){
             
            this.getPsw(psw);
             
        }else if(de.getSource()==passwordField){
            //回车0挂机;1解锁
            if(status==0){
                this.getPsw(psw);
            }else if(status==1){
                this.openKey(psw);
            }
             
        }else if(de.getSource()==delBut){
             
            passwordField.setText("");//设为空
            menu.setVisible(true);//显示系统界面
            this.dispose();
             
        }else if(type.equals("解锁")){
            this.openKey(psw);
             
        }
         
    }
 
    /**
     * 解锁
     * @param psw
     */
    public void openKey(String psw) {
        if(StringUtil.isNotNull(psw)){
            if(psw.equals(key)){
 
                menu.setVisible(true);//显示系统界面
                status=0;//设为set锁回车
                this.dispose();//关闭此窗口
            }else{
                JOptionPane.showMessageDialog(null, "你输入的解锁码不正确");
                passwordField.setText("");//为空
            }
             
        }else{
            JOptionPane.showMessageDialog(null, "请输入解锁码");
        }
    }
 
    /**
     * 设置密码
     * @param psw
     */
    public void getPsw(String psw) {
        if(StringUtil.isNotNull(psw)){
            if(psw.length()>=6){
             
                key=psw;
                yesBut.setText("解锁");
                keyLab.setText("解锁密码:");
                img1.setVisible(true);//显示挂机锁
                yesBut.setForeground(Color.red);
                passwordField.setText("");
                status=1;//设为解锁回车
                 
            }else{
                JOptionPane.showMessageDialog(null, "请设置密码至少6位");
            }
             
        }else{
            JOptionPane.showMessageDialog(null, "请设置密码锁!");
        }
    }
 
}


网友评论    (发表评论)

共1 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...