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

📄 searchscreen.java

📁 java+mysql开发的档案管理系统
💻 JAVA
字号:
package system;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.KeyStroke;

public class SearchScreen extends JFrame implements ActionListener {

	private static final long serialVersionUID = 1L;

	private JLabel msgLabel = new JLabel("档案查询");

	private JLabel infoLabel = new JLabel("请输入你要查询的条件:");

	private JLabel nameLabel = new JLabel("名字");

	private JTextField nameText = new JTextField(20);

	private JLabel idLabel = new JLabel("编号");

	private JTextField idText = new JTextField(20);

	private JLabel partLabel = new JLabel("部门");

	private JComboBox partBox = new JComboBox();

	private JLabel zhiwuLabel = new JLabel("职务");

	private JComboBox zhiwuBox = new JComboBox();

	private JButton okButton = new JButton("查询");

	private JButton cancelButton = new JButton("退出");

	public SearchScreen() {
		super("档案查询");
		initialize();
	}

	public void initialize() {
		this.getContentPane().setLayout(null);
		setSize(600, 400);
		setLocation(250, 200);
		this.setResizable(false);
		msgLabel.setBounds(270, 10, 60, 20);
		infoLabel.setBounds(10, 40, 140, 20);
		nameLabel.setBounds(80, 70, 40, 20);
		idLabel.setBounds(80, 100, 40, 20);
		nameText.setBounds(120, 70, 100, 20);
		idText.setBounds(120, 100, 100, 20);
		partLabel.setBounds(330, 70, 40, 20);
		zhiwuLabel.setBounds(330, 100, 40, 20);
		partBox.setBounds(370, 70, 100, 20);
		partBox.addItem("人事管理部");
		partBox.addItem("后勤部");
		partBox.addItem("财政部");
		zhiwuBox.setBounds(370, 100, 100, 20);
		zhiwuBox.addItem("员工");
		zhiwuBox.addItem("经理");
		this.getContentPane().add(msgLabel);
		this.getContentPane().add(infoLabel);
		this.getContentPane().add(nameLabel);
		this.getContentPane().add(idLabel);
		this.getContentPane().add(partLabel);
		this.getContentPane().add(zhiwuLabel);
		this.getContentPane().add(nameText);
		this.getContentPane().add(idText);
		this.getContentPane().add(partBox);
		this.getContentPane().add(zhiwuBox);
		okButton.setBounds(230, 320, 60, 20);
		cancelButton.setBounds(300, 320, 60, 20);
		this.getContentPane().add(okButton);
		this.getContentPane().add(cancelButton);
		ActionListener s = new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				search();
			}
		};
		this.getRootPane().registerKeyboardAction(s,
				KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false),
				JComponent.WHEN_IN_FOCUSED_WINDOW);
		okButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				search();
			}
		});
		cancelButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});

	}

	public void search() {
		if (nameText.getText().equals("")) {
			JOptionPane.showMessageDialog(null, "用户名不能为空");
			return;
		}
		dispose();
		ShowSearch s = new ShowSearch();
		s.setName(nameText.getText());
		s.setID(idText.getText());
		s.setZhiwu(zhiwuBox.getSelectedItem().toString());
		s.setPart(partBox.getSelectedItem().toString());
		s.repaint();
		s.setVisible(true);
		System.out.println(s.getSql());
		s.showResult();
	}

	public static void main(String args[]) {
		SearchScreen screen = new SearchScreen();
		screen.repaint();
		screen.setVisible(true);
		screen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	public void actionPerformed(ActionEvent arg0) {

	}
}

⌨️ 快捷键说明

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