📄 main.java
字号:
package com.personnel;import java.awt.BorderLayout;import java.awt.Dimension;import java.awt.FlowLayout;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JTabbedPane;import javax.swing.JToolBar;import javax.swing.SwingConstants;import javax.swing.WindowConstants;import org.jdesktop.application.Action;import org.jdesktop.application.Application;import org.jdesktop.application.ApplicationActionMap;import javax.swing.SwingUtilities;public class Main extends javax.swing.JFrame { private static final long serialVersionUID = 1L; private JPanel toolBarPanel; private JLabel label1; private JPanel personnelManageEastPanel; private JPanel personnelManageWestPanel; private JButton employeeInfoButton; private JButton employeeTrainButton; private JButton employeeWantButton; private JToolBar jToolBar2; private JLabel stateBar; private JPanel bottonPanel; private JPanel systemConfigurePanel; private JPanel personnelManagePanel; private JTabbedPane rootPane; private JButton exitButton; private JButton helpButton; private JPanel contentPanel; private JToolBar jToolBar1; private JPanel topPanel; DBTableModel model = null; private JButton adminConfigueButton; private JButton baseInfoConfigueButton; private JToolBar systemConfigueToolBar; private JPanel systemConfigueContentPane; private JPanel systemConfigureToolBar; private JButton printReportButton; private JButton postButton; private JButton jButton1; private JButton examButton; private JButton prizeButton; private JButton fireButton; private JButton depButton; private JButton wanterInfo; DBTableViewer viewer = null; private String admin = null; DBTableModel model1 = null; DBTableViewer viewer1 = null; /** * Auto-generated main method to display this JFrame */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { Main inst = new Main(); inst.setLocationRelativeTo(null); inst.setVisible(true); } }); } public Main() { super(); this.initGUI(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // The frame is placed in the middle; this.setLocation(screenSize.width / 2 - this.getWidth() / 2, screenSize.height / 2 - this.getHeight() / 2); } public Main(String admin) { super(); this.admin = admin; this.initGUI(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // The frame is placed in the middle; this.setLocation(screenSize.width / 2 - this.getWidth() / 2, screenSize.height / 2 - this.getHeight() / 2); } private void initGUI() { try { BorderLayout thisLayout = new BorderLayout(); this.getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setResizable(false); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { System.exit(0); } }); { this.topPanel = new JPanel(); this.getContentPane().add(this.topPanel, BorderLayout.CENTER); BorderLayout topPanelLayout = new BorderLayout(); this.topPanel.setLayout(topPanelLayout); { this.toolBarPanel = new JPanel(); this.topPanel.add(this.toolBarPanel, BorderLayout.NORTH); BorderLayout toolBarPanelLayout = new BorderLayout(); this.toolBarPanel.setLayout(toolBarPanelLayout); { this.jToolBar1 = new JToolBar(); this.toolBarPanel.add(this.jToolBar1, BorderLayout.CENTER); { this.helpButton = new JButton(); this.jToolBar1.add(this.helpButton); this.helpButton.setName("helpButton"); this.helpButton .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { About about = new About(); about.setVisible(true); } }); } { this.exitButton = new JButton(); this.jToolBar1.add(this.exitButton); this.exitButton.setName("exitButton"); this.exitButton.setAction(this.getAppActionMap() .get("exitAction")); } } } { this.contentPanel = new JPanel(); BorderLayout contentPanelLayout = new BorderLayout(); this.contentPanel.setLayout(contentPanelLayout); this.topPanel.add(this.contentPanel, BorderLayout.CENTER); { this.rootPane = new JTabbedPane(); this.contentPanel.add(this.rootPane, BorderLayout.CENTER); { this.personnelManagePanel = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); this.personnelManagePanel.setLayout(jPanel2Layout); this.rootPane.addTab("人事管理", null, this.personnelManagePanel, null); this.personnelManagePanel .setPreferredSize(new java.awt.Dimension( 103, 493)); { this.personnelManageWestPanel = new JPanel(); this.personnelManagePanel.add( this.personnelManageWestPanel, BorderLayout.WEST); { this.jToolBar2 = new JToolBar(); this.personnelManageWestPanel .add(this.jToolBar2); this.jToolBar2 .setPreferredSize(new java.awt.Dimension( 95, 493)); this.jToolBar2 .setOrientation(SwingConstants.VERTICAL); { this.employeeWantButton = new JButton(); this.employeeWantButton .setName("employeeWantButton"); this.employeeWantButton .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { if (Main.this.viewer == null) { Main.this.model = new DBTableModel( DBQuery.SELECT_WANT_ALL_QUERY, "person", "招聘信息"); Main.this.viewer = new DBTableViewer( Main.this, Main.this.model, "招聘信息"); Main.this.personnelManageEastPanel .add(Main.this.viewer); Main.this.pack(); return; } if (Main.this.viewer .getDBTableName() .equals("招聘信息")) { return; } Main.this.personnelManageEastPanel .remove(Main.this.viewer); Main.this.viewer .closeDB(); Main.this.model = new DBTableModel( DBQuery.SELECT_WANT_ALL_QUERY, "person", "招聘信息"); Main.this.viewer = new DBTableViewer( Main.this, Main.this.model, "招聘信息"); Main.this.personnelManageEastPanel .add(Main.this.viewer); Main.this.pack(); } }); } { this.employeeTrainButton = new JButton(); this.employeeTrainButton .setName("employeeTrainButton"); this.employeeTrainButton .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { if (Main.this.viewer == null) { Main.this.model = new DBTableModel( DBQuery.SELECT_TRAIN_ALL_QUERY, "person", "培训课程信息"); Main.this.viewer = new DBTableViewer( Main.this, Main.this.model, "培训课程信息"); Main.this.personnelManageEastPanel .add(Main.this.viewer); Main.this.pack(); return; } if (Main.this.viewer .getDBTableName() .equals( "培训课程信息")) { return; } Main.this.personnelManageEastPanel .remove(Main.this.viewer); Main.this.viewer .closeDB(); Main.this.model = new DBTableModel( DBQuery.SELECT_TRAIN_ALL_QUERY, "person", "培训课程信息"); Main.this.viewer = new DBTableViewer( Main.this, Main.this.model, "培训课程信息"); Main.this.personnelManageEastPanel .add(Main.this.viewer); Main.this.pack(); } }); } { this.employeeInfoButton = new JButton(); this.jToolBar2 .add(this.employeeInfoButton); this.employeeInfoButton .setName("employeeInfoButton"); this.employeeInfoButton .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { if (Main.this.viewer == null) { Main.this.model = new DBTableModel( DBQuery.SELECT_ALL_QUERY, "person", "员工信息"); Main.this.viewer = new DBTableViewer( Main.this, Main.this.model, "员工信息"); Main.this.personnelManageEastPanel .add(Main.this.viewer); Main.this.pack(); return; } if (Main.this.viewer .getDBTableName() .equals("员工信息")) { return; } Main.this.personnelManageEastPanel .remove(Main.this.viewer); Main.this.viewer .closeDB(); Main.this.model = new DBTableModel( DBQuery.SELECT_ALL_QUERY, "person", "员工信息"); Main.this.viewer = new DBTableViewer( Main.this, Main.this.model, "员工信息"); Main.this.personnelManageEastPanel .add(Main.this.viewer); Main.this.pack(); } }); } { this.wanterInfo = new JButton(); this.wanterInfo.setName("wanterInfo"); this.wanterInfo .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { if (Main.this.viewer == null) { Main.this.model = new DBTableModel( DBQuery.SELECT_WANTER_ALL_QUERY, "person", "应聘人员"); Main.this.viewer = new DBTableViewer( Main.this, Main.this.model, "应聘人员"); Main.this.personnelManageEastPanel .add(Main.this.viewer); Main.this.pack(); return; } if (Main.this.viewer .getDBTableName() .equals("应聘人员")) { return; } Main.this.personnelManageEastPanel .remove(Main.this.viewer); Main.this.viewer .closeDB(); Main.this.model = new DBTableModel( DBQuery.SELECT_WANTER_ALL_QUERY, "person", "应聘人员"); Main.this.viewer = new DBTableViewer( Main.this, Main.this.model, "应聘人员"); Main.this.personnelManageEastPanel .add(Main.this.viewer); Main.this.pack(); } }); } { this.fireButton = new JButton(); this.fireButton.setName("fireButton"); this.fireButton .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { if (Main.this.viewer == null) { Main.this.model = new DBTableModel( DBQuery.SELECT_FIRE_ALL_QUERY, "person", "人员录用"); Main.this.viewer = new DBTableViewer( Main.this, Main.this.model, "人员录用"); Main.this.personnelManageEastPanel .add(Main.this.viewer); Main.this.pack(); return; } if (Main.this.viewer .getDBTableName() .equals("人员录用")) { return; } Main.this.personnelManageEastPanel .remove(Main.this.viewer); Main.this.viewer .closeDB(); Main.this.model = new DBTableModel( DBQuery.SELECT_FIRE_ALL_QUERY, "person", "人员录用"); Main.this.viewer = new DBTableViewer(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -