?? add.java
字號:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class Add implements ActionListener{
JFrame fAdd;
JButton commit;
JButton clear;
Container addPane;
Container addPaneMS;
Container addPaneUp;
Container addPaneDown;
JLabel ms;
JLabel workDate;
JLabel regDate;
JLabel content;
JLabel other;
JTextField workDateT, regDateT, contentT, otherT;
ConnectAccess CA2 = new ConnectAccess();
public Add() {
fAdd= new JFrame("Add Frame");
commit = new JButton("添加");
clear = new JButton("重置");
addPane = new JPanel();
addPaneMS = new JPanel();
addPaneUp = new JPanel();
addPaneDown = new JPanel();
ms = new JLabel("添加記錄");
regDate = new JLabel("登記日期 : ");
regDateT = new JTextField("");
workDate = new JLabel("應辦日期 : ");
workDateT = new JTextField("");
content = new JLabel("日程內容 : ");
contentT = new JTextField("");
other = new JLabel("備注 : ");
otherT = new JTextField("");
fAdd.add(addPane);
addPane.setLayout(new BorderLayout());
addPane.add("North", addPaneMS);
addPane.add("Center", addPaneUp);
addPane.add("South", addPaneDown);
addPaneUp.setLayout(new GridLayout(5, 2));
addPaneDown.setLayout(new GridLayout(1, 2));
addPaneMS.setLayout(new GridLayout(1, 1));
addPaneMS.add(ms, SwingConstants.CENTER);
ms.setForeground(Color.red);
ms.setFont(new Font("TRUE", Font.TRUETYPE_FONT, 20));
addPaneUp.add(regDate);
//addPaneUp.add(new JLabel("登記日期"), SwingConstants.CENTER);
addPaneUp.add(regDateT);
addPaneUp.add(workDate);
addPaneUp.add(workDateT);
addPaneUp.add(content);
addPaneUp.add(contentT);
addPaneUp.add(other);
addPaneUp.add(otherT);
addPaneDown.add(commit);
addPaneDown.add(clear);
commit.addActionListener(this);
clear.addActionListener(this);
CA2.createConn_Direct();
fAdd.setSize(400, 300);
fAdd.show();
}
public void addCommit() {
RecordType rt= new RecordType();
if (workDateT.getText().length()==0 || contentT.getText().length()==0)
JOptionPane.showMessageDialog(null, "請將信息填寫完整!");
else {
rt.setRegDate(regDateT.getText());
rt.setWorkDate(workDateT.getText());
rt.setContent(contentT.getText());
rt.setOther(otherT.getText());
CA2.addData(rt);
JOptionPane.showMessageDialog(null, "添加成功!");
}
}
public void addClear() {
regDateT.setText("");
workDateT.setText("");
contentT.setText("");
otherT.setText("");
}
public void actionPerformed(ActionEvent e){
if (e.getSource() == commit)
addCommit();
else if (e.getSource() == clear)
addClear();
}
public static void main(String[] args) {
Add Add1 = new Add();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -