?? mainui.java
字號:
package view;
import java.awt.Dialog;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import logic.logic;
//主管理界面
public class mainUI extends JFrame implements ActionListener{
private ButtonGroup bgsss = new ButtonGroup();
private ButtonGroup bgins = new ButtonGroup();
private ButtonGroup bgsts = new ButtonGroup();
private ButtonGroup bgtin = new ButtonGroup();
logic ld=new logic();
int cw=800; //-------------------------------------------測試寬度
int ch=520; //-------------------------------------------測試高度
int sx=0; //測試起點坐標x
int sy=40; //測試起點坐標y
Vector vchead=new Vector();//班級查詢后列名
Vector zytbhead=new Vector();//專業查詢后的表列名
Vector thead=new Vector();//教師查詢后列名
Vector vsthead=new Vector();//學生查詢后列名
//----------------------------------------------------------------------------單選鈕
//-------------教師面板上的
JRadioButton tinman = new JRadioButton();//教師錄入面板男
JRadioButton tinwoman = new JRadioButton();//教師上女
JRadioButton rtsman = new JRadioButton();//要查的教師性別男
JRadioButton rtswoman = new JRadioButton();//要查的教師性別女
//------------學生錄入面板上的
JRadioButton sinsman = new JRadioButton();//錄入學生性別 男
JRadioButton sinswoman = new JRadioButton();//錄入學生性別女
//-------------學生查詢
JRadioButton ssman = new JRadioButton();//查詢的學生性別 男
JRadioButton sswoman = new JRadioButton(); //查詢的學生性別 女
//----------------------------------------------------------------------------復選框
JCheckBox cbuscname = new JCheckBox();//使用班名查詢
JCheckBox cbuscstatus = new JCheckBox();//使用班狀態查詢
JCheckBox cbusbzrm = new JCheckBox();//使用班主任名查詢
//--------------------------------------------------
JCheckBox cbssname = new JCheckBox();//使用學生姓名查詢復選框
JCheckBox cbsssex = new JCheckBox();//使用學生性別查詢
JCheckBox cbssage = new JCheckBox();//使用學生年齡查詢
JCheckBox cbssyear = new JCheckBox();//使用學生入學年份查詢
JCheckBox cbsszy = new JCheckBox();//使用學生專業查詢
JCheckBox cbssclass = new JCheckBox();//使用學生所在班級查詢
JCheckBox cbssstatus = new JCheckBox();//使用學生狀態查詢
//---------------教師查詢面板
JCheckBox cbtsname = new JCheckBox();//姓名
JCheckBox cbtssex = new JCheckBox();//性別
JCheckBox cbtsage = new JCheckBox();//年齡
JCheckBox cbtsinwork = new JCheckBox();//入職日期
JCheckBox cbtsstat = new JCheckBox();//使用教師工作狀態進行查詢
JCheckBox cbzyname = new JCheckBox();//使用專業名查詢復選框
JCheckBox cbzyms = new JCheckBox();//使用專業描述查詢復選框
//-----------------------------------------------------------------------------下拉列表
JComboBox cbtmonth = new JComboBox();//教師入職月份
JComboBox cbtstatus = new JComboBox();//教師狀態in
JComboBox jcbtinage = new JComboBox();//要插入的教師年齡
JComboBox jcbtsts = new JComboBox();//要查詢的教師狀態
JComboBox jcbtsage = new JComboBox();//要查詢的教師年齡
JComboBox banzhurenming = new JComboBox();//班級面板上班主任名字
JComboBox cbcmonth = new JComboBox();//班級面板上月份
JComboBox cbcday = new JComboBox();//班級面板上日
JComboBox cbincstatus = new JComboBox();//班級面板上班狀態
JComboBox cbscstat = new JComboBox();//要查詢的班級狀態
JComboBox cbsinmonth = new JComboBox();//要錄入的學生入學年份
JComboBox cbszhuanye = new JComboBox();//學生上所選專業
JComboBox cbsclass = new JComboBox();//學生面板中所在班級
JComboBox cbinsstatus = new JComboBox();//要錄入的學生狀態
JComboBox cbsszhuanye = new JComboBox();//要查詢的學生專業
JComboBox cbsssclass = new JComboBox();//要查詢的學生班級
JComboBox cbsstatuss = new JComboBox();//要查詢的學生狀態
//----------------------------------------------------------------------------------菜單
JMenuItem musersm = new JMenuItem();//用戶管理
JMenuItem mcontest = new JMenuItem();// 測試數據庫連接
JMenuItem moffconn = new JMenuItem();//斷開數據庫
JMenuItem mexita = new JMenuItem();//退出main
JMenuItem minclass = new JMenuItem();//班級信息錄入
JMenuItem mseclass = new JMenuItem();//班級信息查詢
JMenuItem minteacher = new JMenuItem();//教師錄入
JMenuItem mseteacher = new JMenuItem();//教師查詢
JMenuItem minstudent = new JMenuItem();//錄入學生
JMenuItem msestudent = new JMenuItem();//查詢學生
JMenuItem minzy = new JMenuItem();//錄入專業
JMenuItem msezy = new JMenuItem();//專業信息查詢
//----------------------------------------------------------------------------------------文本框
//-------------班級面板上的
JTextField tfcid = new JTextField();//班級面板上的班號
JTextField tfcyear = new JTextField();//要插入的開班年份
JTextField tfcname = new JTextField();//班級面板上班名
JTextField tfcmansum = new JTextField();//班級人數
JTextArea tacbz = new JTextArea();//班級備注
//-------------班級查詢面板上的
JTextField tfscname = new JTextField();//要查詢的班名
JTextField tfscbzname = new JTextField();//要查詢班級的班主任名
//---------------學生面板上的
JTextField tfsinid = new JTextField();//學生要錄入的學生編號
JTextField tfsinname = new JTextField();//學生要錄入的學生名
JTextField tfinsage = new JTextField();//要錄入的學生年齡
JTextField tfinsyear = new JTextField();//要錄入的學生年份
JTextField tfinssfid = new JTextField();//要錄入的學生身份證號
JTextField tfinsnowaddres = new JTextField();//要錄入的學生住址
JTextField tfinsphone = new JTextField();//要錄入的學生電話
//------------學生查詢面板上的
JTextField tfssname = new JTextField();//學生查詢上的要查詢的學生名
JTextField tfssage = new JTextField();//要查詢的學生年齡
JTextField tfssindate = new JTextField();//要查詢的學生入學年份
//--------------教師面板上的
JTextField tftid = new JTextField();//教師編號
JTextField tftname = new JTextField();//教師姓名
JTextField tftyear = new JTextField();//教師入職年份
JTextField tftsfid = new JTextField();//教師身份證號
JTextField tfnaddr = new JTextField();//教師現住址
JTextField tftphone = new JTextField();//手機號
//--教師查詢面板上
JTextField tftsname = new JTextField();//要杳的教師名
JTextField tftsinworkyear = new JTextField();// 要查的入職年份
//-------------------專業面板上的
JTextField tfzyid = new JTextField();//專業面板上專業編號
JTextField tfzyname = new JTextField();//專業面板上要錄入的專業名
JTextArea tazyms = new JTextArea();//專業面板上要錄入的專業描述
JTextArea tazybz = new JTextArea();//專業面板要錄入的專業備注
JTextField tfszyname = new JTextField();//專業面板上要查詢的專業名
JTextField tfszyms = new JTextField();//要查詢的專業描述
//-------------------------------------------------------------------------------------按鈕
JButton btclass = new JButton(); //班級管理在main上的
JButton btexitclassp = new JButton();//班級面板上退出
JButton btinclass = new JButton();//班級面板上錄入
JButton btmoclass = new JButton();//班級面板上修改
JButton btdelclass = new JButton();//班級面板上刪除
JButton btsclass = new JButton();//班級查詢面板上查詢
JButton btsmclass = new JButton();//班級查詢面板上修改
JButton btsdelclass = new JButton();//班級查詢上刪除
JButton btteacher = new JButton(); //教師管理在main上的
JButton btinteacher = new JButton();//教師面板上錄入按鈕
JButton btmodifyteacher = new JButton();//修改
JButton btdelteacher = new JButton();//教師錄入上刪除
JButton btexitteacherp = new JButton();//退出教師面板
JButton btsearcht = new JButton();//教師查詢面板上的查詢
JButton btmots = new JButton();//教師查詢面板上的修改
JButton btsdelt = new JButton();//教師查詢上刪除
JButton btstudent = new JButton();//學生管理在main上的
JButton btinstudent = new JButton();//學生面板上錄入
JButton btmodifystudent = new JButton();//學生錄入上修改
JButton btdelstudent = new JButton();//學生錄入刪除
JButton btmostudent = new JButton();//學生查詢上修改
JButton btdelsst = new JButton();//學生查詢上的刪除
JButton btsstudent = new JButton();//學生查詢上查詢
JButton btexitstudentp = new JButton();//學生面板上的退出
JButton btzhuanye = new JButton();//專業管理在main上的
JButton btinzy = new JButton();//專業面板上錄入
JButton btmozy = new JButton();//專業錄入上修改
JButton btmozys = new JButton();//專業查詢上修改專業
JButton btdelzy = new JButton();//專業錄入上刪除
JButton btsdelzy = new JButton();//專業查詢上刪除
JButton btexitzhuanyep = new JButton();//專業面板上的退出
JButton btsearchzy = new JButton();//專業面板上查詢
JButton btuserm = new JButton();//用戶管理在main上的
JButton btexita = new JButton();//退出 在main上的
//-------------------------------------------------------------------------------------面板
//-----------------分頁面板
JTabbedPane classtabpanel = new JTabbedPane();//班級的總分頁面板
JTabbedPane teachertabbedPane = new JTabbedPane();//教師的分頁面板
JTabbedPane studenttabbedPane = new JTabbedPane();//學生的分頁面板
JTabbedPane tbpzy = new JTabbedPane();//專業的分頁面板
//-----------------------------------------
JPanel classpanel = new JPanel();// 班級管理總面板
JPanel teacherpanel = new JPanel();//教師管理總面板
JPanel studentpanel = new JPanel();//學生管理總面板
JPanel zhuanyepanel = new JPanel();//專業管理總面板
JScrollPane sczy = new JScrollPane();//專業查詢滾動面板
//----------------------------------------------------------------------------------表格模板
DefaultTableModel dtmcs=new DefaultTableModel();//班級面板查詢的模板
DefaultTableModel dtmzy=new DefaultTableModel();//專業面板查詢的模板
DefaultTableModel dtmtr=new DefaultTableModel();//教師查詢的模板
DefaultTableModel dtmst=new DefaultTableModel();//學生查詢的模板
// -------------------------------------------------------------------------------------表格
JTable tbclass = new JTable(dtmcs);//班級面板上的查詢結果
JTable tablesearchs = new JTable(dtmst);//學生面板查詢結果
JTable tablezy = new JTable(dtmzy);//專業面板上的查詢結果
JTable tablesteacher = new JTable(dtmtr);//教師查詢后的結果表格
/**
* 初始化班級信息
*
*/
public void initClassInfo(){
tfcid.setText(ld.getClassid()+"");//再次初始化要插入的班級編號
cbsssclass.setModel(new DefaultComboBoxModel(ld.getName("classt", "cname")));//重新初始化查詢學生面板中班級
cbsclass.setModel(new DefaultComboBoxModel(ld.getName("classt", "cname")));//重新初始化學生面板中班級
tfcyear.setText("");
cbcmonth.setSelectedIndex(0);
cbcday.setSelectedIndex(0);
tfcname.setText("");
tfcmansum.setText("");
banzhurenming.setSelectedIndex(0);
cbincstatus.setSelectedIndex(0);
tacbz.setText("");
}
/**
* 初始脂教師信息
*
*/
public void initTeacherInfo(){
tftid.setText(ld.getTeacherid()+"");//如果添加成功重新加一個教師編號
banzhurenming.setModel(new DefaultComboBoxModel(ld.getName("teachert", "tname")));//并重新初始化班級面板中班主任名字
tftname.setText("");
tinman.setSelected(true);
tinwoman.setSelected(false);
jcbtinage.setSelectedIndex(0);
tftyear.setText("");
cbtmonth.setSelectedIndex(0);
tftsfid.setText("");
tfnaddr.setText("");
tftphone.setText("");
cbtstatus.setSelectedIndex(0);
}
/**
* 初始化專業信息
*
*/
public void initZhuanyeInfo(){
tfzyid.setText(ld.getZhuanyeid()+"");//刪除完成后重新加一個編號
tfzyname.setText("");
tazyms.setText("");
tazybz.setText("");
dtmzy.setDataVector(ld.searchResult(cbzyname.isSelected(), cbzyms.isSelected(), tfszyname.getText(), tfszyms.getText()), zytbhead);
cbszhuanye.setModel(new DefaultComboBoxModel(ld.getName("zhuanyet", "zyname")));//重新初始化學生面板中專業
cbsszhuanye.setModel(new DefaultComboBoxModel(ld.getName("zhuanyet", "zyname")));//重新初始化查詢學生面板中專業
}
/**
* 初始化學生信息
*
*/
public void initStudentInfo(){
tfsinid.setText("");
tfsinname.setText("");
sinswoman.setSelected(false);
sinsman.setSelected(true);
tfinsage.setText("");
tfinsyear.setText("");
cbsinmonth.setSelectedIndex(0);
cbszhuanye.setSelectedIndex(0);
cbsclass.setSelectedIndex(0);
tfinssfid.setText("");
tfinsnowaddres.setText("");
tfinsphone.setText("");
tfsinid.setText(ld.getStudentid()+"");//初始化學生id
cbinsstatus.setSelectedIndex(0);
}
//初始化監聽器及一此序列號
public void init(){
cbsszhuanye.setModel(new DefaultComboBoxModel(ld.getName("zhuanyet", "zyname")));//初始化查詢學生面板中專業
cbszhuanye.setModel(new DefaultComboBoxModel(ld.getName("zhuanyet", "zyname")));//初始化學生面板中專業
cbsclass.setModel(new DefaultComboBoxModel(ld.getName("classt", "cname")));//初始化學生面板中班級
cbsssclass.setModel(new DefaultComboBoxModel(ld.getName("classt", "cname")));//初始化查詢學生面板中班級
banzhurenming.setModel(new DefaultComboBoxModel(ld.getName("teachert", "tname")));//初始化班級面板中班主任名字----------------------
tbpzy.isFocusable();
btclass.addActionListener(this);
btteacher.addActionListener(this);
btstudent.addActionListener(this);
btinstudent.addActionListener(this);//學生面板上錄入
btmodifystudent.addActionListener(this);//學生錄入上修改
btdelstudent.addActionListener(this);//學生錄入刪除
btsstudent.addActionListener(this);//學生面板上查詢
btmostudent.addActionListener(this);//學生查詢上修改
btdelsst.addActionListener(this);//學生查詢上刪除
btzhuanye.addActionListener(this);
btexitclassp.addActionListener(this);//班級面板退出
btinclass.addActionListener(this);//班級面板上錄入
btmoclass.addActionListener(this);//班級面板上修改
btdelclass.addActionListener(this);//班級面板上刪除
btsclass.addActionListener(this);//班級面板上給我查
btsmclass.addActionListener(this);//查詢面板上修改
btsdelclass.addActionListener(this);//班級查詢上刪除
btexitstudentp.addActionListener(this);//學生上的退出加
btinteacher.addActionListener(this);//添加教師監聽
btmodifyteacher.addActionListener(this);//錄入上的修改
btsearcht.addActionListener(this);//教師查詢監聽
btmots.addActionListener(this);//教師查詢面板上修改
btsdelt.addActionListener(this);//教師查詢上刪除
btdelteacher.addActionListener(this);//教師錄入上刪除
btexitteacherp.addActionListener(this);//退出教師面板
btinzy.addActionListener(this);//專業面板上的錄入加監聽
btmozy.addActionListener(this);//專業錄入上修改
btdelzy.addActionListener(this);//專業錄入面板上刪除
btexitzhuanyep.addActionListener(this);//專業退出加
btsearchzy.addActionListener(this);//專業面板上的查詢按鈕加
btmozys.addActionListener(this);//專業修改
btsdelzy.addActionListener(this);
btuserm.addActionListener(this);//用戶管理
btexita.addActionListener(this);//main上退出
musersm.addActionListener(this);//用戶管理
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -