⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workerob.java

📁 员工管理系统 在一个公司里员工之间都有工作上的联系。对方的联系方式
💻 JAVA
字号:
package com.worker.userpan;

import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import java.awt.datatransfer.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import java.util.*;

import com.tool.*;
import com.worker.db.*;
import com.worker.information.*;
import com.worker.main.*;
import com.worker.userpan.*;

/**
 *
 * @author Administrator
 */
public abstract class WorkerOb {
    protected Worker workerdata;
    protected MainPanel main;
    protected DbCon dbcon;
    
    public abstract String getTitle();
    public abstract JMenuBar getmenubar();
    public abstract JPanel getpanel();
    public abstract JTabbedPane gettabbedpane();
    
    protected class LoginAction extends AbstractAction {
        
        // set up action's name, icon, descriptions and mnemonic
        public LoginAction() {
            putValue( NAME, " 登陆(E) " );
            putValue( SMALL_ICON, new ImageIcon(
                    getClass().getResource( "images/Login.png" ) ) );
            putValue( SHORT_DESCRIPTION, " 注销并登陆 " );
            putValue( MNEMONIC_KEY, new Integer( 'E' ) );
        }
        
        // display window in which user can input entry
        public void actionPerformed( ActionEvent e ) {
            main.requestLogin();
        }
        
    }  // end inner class NewAction
    //exit the environment and inform to register an unathority access
    
    protected class LockAction extends AbstractAction {
        
        // set up action's name, icon, descriptions and mnemonic
        public LockAction() {
            putValue( NAME, " 锁定(P) " );
            putValue( SMALL_ICON, new ImageIcon(
                    getClass().getResource( "images/Lock.png" ) ) );
            putValue( SHORT_DESCRIPTION, " 锁定保护 " );
            putValue( MNEMONIC_KEY, new Integer( 'P' ) );
        }
        
        // display window in which user can input entry
        public void actionPerformed( ActionEvent e ) {
            freezePro();
        }
        
    }  // end inner class NewAction
    protected void freezePro() {
        
        class freDia extends JDialog {
            JPasswordField pass = new JPasswordField(8);
            
            public freDia() {
                setTitle(" 请输入你用户的登陆密码 ");
                setModal(false);
                setSize(250,100);
                setLocation( ToolKit.getScreenCenterLocation(getSize()) );
                setResizable(false);
                
                JPanel pan=new JPanel();
                pass.setEchoChar('*');
                pan.add(pass,BorderLayout.NORTH);
                
                JPanel bpan=new JPanel();
                JButton okb=new JButton(" 确认 ");
                okb.addActionListener( new ActionListener( ) {
                    public void actionPerformed( final ActionEvent sub ) {
                        okaction(); }
                } ) ;
                bpan.add(okb,BorderLayout.WEST);
                
                JButton exitb=new JButton(" 注销 ");
                exitb.addActionListener( new ActionListener( ) {
                    public void actionPerformed( final ActionEvent sub ) {
                        unregisteraction();
                    }
                } ) ;
                bpan.add(exitb,BorderLayout.EAST);
                
                pan.add(bpan,BorderLayout.CENTER);
                this.add(pan);
                
                addWindowListener( new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {
                        exitaction();
                    }
                });
                
                this.setVisible(true);
            }
            
            public void okaction() {
                String valpass=new String(pass.getPassword());
                if (valpass!=null && workerdata.getuserp()!=null && valpass.equals(workerdata.getuserp()) ) {
                    this.setVisible(false);
                    main.setVisible(true);
                } else {
                    pass.setText("");
                }
            }
            
            public void unregisteraction() {
                freeResource();
                this.setVisible(false);
                main.requestLoginAnonymous();
            }
            //unregister is an anonymous observe way to the environment
            public void exitaction() {
                new freDia();
            }
        }
        
        main.setVisible(false);
        new freDia();
    }
    //protect to lock the data when you left
    
    protected class UnregAction extends AbstractAction {
        
        // set up action's name, icon, descriptions and mnemonic
        public UnregAction() {
            putValue( NAME, " 注销(L) " );
            putValue( SMALL_ICON, new ImageIcon(
                    getClass().getResource( "images/Exit.png" ) ) );
            putValue( SHORT_DESCRIPTION, " 退出当前用户 " );
            putValue( MNEMONIC_KEY, new Integer( 'L' ) );
        }
        
        // display window in which user can input entry
        public void actionPerformed( ActionEvent e ) {
            freeResource();
            main.requestLoginAnonymous();
        }
        
    }  // end inner class NewAction
    //unregister the current user
    
    protected class ExitAction extends AbstractAction {
        
        // set up action's name, icon, descriptions and mnemonic
        public ExitAction() {
            putValue( NAME, " 退出(X) " );
            putValue( SMALL_ICON, new ImageIcon(
                    getClass().getResource( "images/Exit.png" ) ) );
            putValue( SHORT_DESCRIPTION, " 离开系统 " );
            putValue( MNEMONIC_KEY, new Integer( 'X' ) );
        }
        
        // display window in which user can input entry
        public void actionPerformed( ActionEvent e ) {
            main.freetoExit();
        }
        
    }  // end inner class NewAction
    //distroy the frame and free the momery to exit
    
    protected void freeResource() {
        DbCon.getinstance().close();
    }
    //free the database in case of overflow
    
    public void setmainFrame(MainPanel va) {
        this.main=va;
    }
    //add the mainframe instance to hide frame or to has an access to login or exit;
    
    public void setworker(Worker va) {
        this.workerdata=va;
    }
    //add the woker information
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -