Java办公系统增加与查询

纯干货,直接展示。

界面展示:

Java源码:

package 暑假作业1;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Addframe extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;

	/**
	 * Launch the application.
	 */
//	public static void main(String[] args) {
//		EventQueue.invokeLater(new Runnable() {
//			public void run() {
//				try {
//					Addframe frame = new Addframe();
//					frame.setVisible(true);
//				} catch (Exception e) {
//					e.printStackTrace();
//				}
//			}
//		});
//	}

	/**
	 * Create the frame.
	 */
	public Addframe() {
		setTitle("\u529E\u516C\u7528\u54C1\u7C7B\u522B");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JLabel lblNewLabel = new JLabel("\u7C7B\u522B\u7F16\u7801");
		lblNewLabel.setBounds(104, 61, 54, 26);
		contentPane.add(lblNewLabel);

		JLabel lblNewLabel_1 = new JLabel("\u7C7B\u522B\u540D\u79F0");
		lblNewLabel_1.setBounds(104, 110, 54, 26);
		contentPane.add(lblNewLabel_1);

		textField = new JTextField();
		textField.setBounds(171, 60, 155, 29);
		contentPane.add(textField);
		textField.setColumns(10);

		textField_1 = new JTextField();
		textField_1.setBounds(171, 109, 155, 29);
		contentPane.add(textField_1);
		textField_1.setColumns(10);

		JButton btnNewButton = new JButton("\u4FDD\u5B58");// 保存
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String st1 = textField.getText();
				String st2 = textField_1.getText();
				if(st1.equals("")||st2.equals("")) {
					JOptionPane.showConfirmDialog(null, "插入为空!", "提示", JOptionPane.PLAIN_MESSAGE);
				}else {				
				Dao dao = new Dao();
				int result = dao.Add(st1, st2);
				if (result > 0) {
					JOptionPane.showConfirmDialog(null, "插入成功!", "提示", JOptionPane.PLAIN_MESSAGE);
					Mainframe mainframe=new Mainframe();
				    mainframe.setVisible(true);
				    Addframe.this.dispose();
				} else {
					JOptionPane.showConfirmDialog(null, "插入失败!", "提示", JOptionPane.PLAIN_MESSAGE);
				}
				}

				textField.setText("");
				te
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值