?? zjkcframe.java
字號:
package com.jm;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.lj.LianJie;
//定義增加課程界面
public class Zjkcframe {
JFrame frame;
JPanel p1,p2,p3,p4,p5,p6,p7,p8,p9;
JTextField t1,t2,t3,t4,t5,t6,t7;
JButton b1,b2;
public void setzjkcframe() {
frame = new JFrame();
frame.setLocation(200,300);
frame.setSize(300, 400);
frame.setTitle("增加課程");
frame.setLayout(new GridLayout(9,1));
p1 = new JPanel();
p2 = new JPanel();
p3 = new JPanel();
p4 = new JPanel();
p5 = new JPanel();
p6 = new JPanel();
p7 = new JPanel();
p8 = new JPanel();
p9 = new JPanel();
p1.setBackground(Color.white);
p2.setBackground(Color.white);
p3.setBackground(Color.white);
p4.setBackground(Color.white);
p5.setBackground(Color.white);
p6.setBackground(Color.white);
p7.setBackground(Color.white);
p8.setBackground(Color.white);
p9.setBackground(Color.white);
frame.add(p1);
frame.add(p2);
frame.add(p3);
frame.add(p4);
frame.add(p5);
frame.add(p6);
frame.add(p7);
frame.add(p8);
frame.add(p9);
p1.add(new JLabel("請認真填寫要增加的課程信息:"));
p2.add(new JLabel("課程編號:"));
t1 = new JTextField(10);
p2.add(t1);
p3.add(new JLabel("課程名稱"));
t2 = new JTextField(10);
p3.add(t2);
p4.add(new JLabel("任課教師:"));
t3 = new JTextField(10);
p4.add(t3);
p5.add(new JLabel("開課時間:"));
t4 = new JTextField(10);
p5.add(t4);
p6.add(new JLabel("所需課時:"));
t5 = new JTextField(10);
p6.add(t5);
p7.add(new JLabel("上課地點:"));
t6 = new JTextField(10);
p7.add(t6);
p8.add(new JLabel("限報人數(shù):"));
t7 = new JTextField(10);
p8.add(t7);
b1 = new JButton("提交");
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
LianJie lj = new LianJie();
String sql = "insert into kc values('"+t1.getText()+"','"+t2.getText()+"','"+t3.getText()+"','"+t4.getText()+"','"+t5.getText()+"','"+t6.getText()+"','"+t7.getText()+"')";
lj.Update(sql);
frame.dispose();
}
});
b2 = new JButton("取消");
b2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
}
});
p9.add(b1);
p9.add(b2);
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
frame.setResizable(false);
frame.setVisible(true);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -