📄 searchstaffinfo.java
字号:
/*
* SearchStaffInfo.java
*
* Created on 2007年1月19日, 上午5:09
*/
package javaapplication1;
import java.awt.Toolkit;
import java.sql.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.*;
/**
*
* @author lab
*/
public class SearchStaffInfo extends javax.swing.JFrame {
private DefaultTableModel staffModel = null;
private JTable tableStaff = null;
/** Creates new form SearchStaffInfo */
public SearchStaffInfo(JTable table,DefaultTableModel tm) {
this.staffModel = tm;
this.tableStaff = table;
connectDB();
initComponents();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
//-------设置窗口位置居中---------------------------------------------------------------
int locationX=(int)(Toolkit.getDefaultToolkit().getScreenSize().getWidth()-getSize().getWidth())/2;
int locationY=(int)(Toolkit.getDefaultToolkit().getScreenSize().getHeight()-getSize().getHeight())/2;
setLocation(locationX,locationY);
//--------------------------------------------------------------------------------------
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
IDField = new javax.swing.JTextField();
nameField1 = new javax.swing.JTextField();
nameField2 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
searchButton1 = new javax.swing.JButton();
sexComboBox = new javax.swing.JComboBox();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
salaryComboBox = new javax.swing.JComboBox();
searchButton2 = new javax.swing.JButton();
jLabel9 = new javax.swing.JLabel();
searchButton3 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel3.setText("\u7cbe\u786e\u67e5\u8be2\uff1a");
jLabel4.setText("\u6a21\u7cca\u67e5\u8be2\uff1a");
jLabel1.setText("\u5458\u5de5\u53f7");
jLabel2.setText("\u7ec4\u5408\u67e5\u8be2\uff1a");
jLabel5.setText("\u59d3\u540d");
searchButton1.setText("\u67e5\u8be2");
searchButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
searchButton1ActionPerformed(evt);
}
});
sexComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "\u7537", "\u5973" }));
jLabel6.setText("\u6027\u522b");
jLabel7.setText("\u85aa\u6c34");
salaryComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1000\u4ee5\u4e0b", "1000-2000", "2000-3000", "3000-4000", "4000-5000", "5000\u4ee5\u4e0a" }));
searchButton2.setText("\u67e5\u8be2");
searchButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
searchButton2ActionPerformed(evt);
}
});
jLabel9.setText("\u59d3\u540d");
searchButton3.setText("\u67e5\u8be2");
searchButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
searchButton3ActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(209, Short.MAX_VALUE)
.add(searchButton3)
.add(182, 182, 182))
.add(layout.createSequentialGroup()
.add(125, 125, 125)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(jLabel4)
.addContainerGap())
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(searchButton2)
.add(192, 192, 192))
.add(layout.createSequentialGroup()
.add(jLabel2)
.addContainerGap())
.add(layout.createSequentialGroup()
.add(jLabel3)
.addContainerGap())
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel9)
.add(jLabel1)
.add(jLabel7)
.add(jLabel6)
.add(jLabel5))
.add(28, 28, 28)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(10, 10, 10)
.add(searchButton1)
.add(192, 192, 192))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(org.jdesktop.layout.GroupLayout.LEADING, nameField2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
.add(IDField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, salaryComboBox, 0, 103, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, sexComboBox, 0, 103, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, nameField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE))
.add(156, 156, 156)))))))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel3)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(IDField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(searchButton1)
.add(14, 14, 14)
.add(jLabel2)
.add(14, 14, 14)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(nameField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel5))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(sexComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel6))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(salaryComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel7))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(searchButton2)
.add(34, 34, 34))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jLabel4)
.add(17, 17, 17)))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel9)
.add(nameField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(searchButton3)
.addContainerGap(39, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
//模糊查询代码
private void searchButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButton3ActionPerformed
// TODO 将在此处添加您的处理代码:
String name = nameField2.getText();
String staffID = "";
String sex = "";
String date;
String salary;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -