?? classframsourse.java
字號:
package Course;
import java.awt.*;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.BorderLayout;
import javax.swing.table.DefaultTableModel;
import java.awt.Rectangle;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ClassFramSourse extends JFrame implements ActionListener{
private CourseSys CourseSys1;
Save_Load data=new Save_Load();
JPanel contentPane;
JTabbedPane jTabbedPane1 = new JTabbedPane();
JPanel ClassInput = new JPanel();
JPanel studentInput = new JPanel();
JPanel scoreIn = new JPanel();
JPanel search = new JPanel();
JScrollPane jScrollPane1 = new JScrollPane();
final Object[] columnNames = {"年級","專業", "班別","學生人數"};
Object[][] rowData = {};
DefaultTableModel model = new DefaultTableModel(rowData,columnNames){public boolean isCellEditable(int row, int column) {return false;}};
JTable jTable1 = new JTable(model);
JLabel jLabel1 = new JLabel();
JTextField ClassInText1 = new JTextField();
JLabel jLabel2 = new JLabel();
JTextField ClassInText2 = new JTextField();
JLabel jLabel3 = new JLabel();
JTextField ClassInText3 = new JTextField();
JLabel jLabel4 = new JLabel();
JTextField ClassInText4 = new JTextField();
JButton ClassInOK = new JButton();
JButton jButton3 = new JButton();
JButton SaveOK = new JButton();
JLabel jLabel5 = new JLabel();
JComboBox StuInBox = new JComboBox();
JButton StuInOk = new JButton();
JButton ScoreInOK = new JButton();
JLabel jLabel6 = new JLabel();
JComboBox ScoreInBox1 = new JComboBox();
JComboBox SearchBox1 = new JComboBox();
JLabel jLabel7 = new JLabel();
JTabbedPane jTabbedPane2 = new JTabbedPane();
JPanel jPanel1 = new JPanel();
JPanel NumModel = new JPanel();
JPanel jPanel3 = new JPanel();
JPanel LineModel = new JPanel();
JPanel CircleModel = new JPanel();
JComboBox SearchBox2 = new JComboBox();
JLabel 科目 = new JLabel();
JLabel jLabel8 = new JLabel();
JComboBox ScoreInBox2 = new JComboBox();
JLabel jLabel9 = new JLabel();
//
JScrollPane jScrollPane2 = new JScrollPane();
final Object[] columnNames1 = {"學號","姓名"};
DefaultTableModel model1 = new DefaultTableModel(rowData,columnNames1);
JTable jTable2 = new JTable(model1);
//
final Object[] columnNames2= {"學號","姓名", "分數"};
DefaultTableModel model2 = new DefaultTableModel(rowData,columnNames2){public boolean isCellEditable(int row, int column) {if(column==2)return true;else return false;}};
JScrollPane jScrollPane3 = new JScrollPane();
JTable jTable3 = new JTable(model2);
final Object[] columnNames3= {"基本信息","信息設置"};
Object[][] rowData3= {{"課程編號",null},{"課程名稱",null},{"課程學分",null},{"課程學時",null},{"考試時間",null},{"選課人數",null}};
DefaultTableModel model3 = new DefaultTableModel(rowData3,columnNames3){public boolean isCellEditable(int row, int column) {if(column==1)return true;else return false;}};
JScrollPane jScrollPane4 = new JScrollPane();
JTable jTable4 = new JTable(model3); //
JPanel jPanel2 = new JPanel();
JButton ClassDel = new JButton();
JButton CourseDel = new JButton();
public ClassFramSourse() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(null);
setSize(new Dimension(476, 465));
setTitle("Frame Title");
ClassInput.setLayout(null);
jScrollPane1.setBounds(new Rectangle(16, 6, 414, 190));
jTabbedPane1.setBounds(new Rectangle(5, 13, 455, 419));
jLabel1.setFont(new java.awt.Font("宋體", Font.PLAIN, 16));
jLabel1.setText("年級");
jLabel1.setBounds(new Rectangle(27, 222, 101, 26));
ClassInText1.setFont(new java.awt.Font("宋體", Font.PLAIN, 16));
ClassInText1.setBounds(new Rectangle(108, 224, 103, 23));
jLabel2.setFont(new java.awt.Font("宋體", Font.PLAIN, 16));
jLabel2.setText("專業");
jLabel2.setBounds(new Rectangle(27, 256, 67, 28));
ClassInText2.setFont(new java.awt.Font("宋體", Font.PLAIN, 16));
ClassInText2.setDisabledTextColor(Color.black);
ClassInText2.setBounds(new Rectangle(107, 262, 104, 21));
jLabel3.setFont(new java.awt.Font("宋體", Font.PLAIN, 16));
jLabel3.setText("班級");
jLabel3.setBounds(new Rectangle(27, 288, 61, 29));
ClassInText3.setFont(new java.awt.Font("宋體", Font.PLAIN, 16));
ClassInText3.setBounds(new Rectangle(107, 291, 104, 22));
jLabel4.setFont(new java.awt.Font("宋體", Font.PLAIN, 16));
jLabel4.setText("人數");
jLabel4.setBounds(new Rectangle(27, 317, 62, 25));
ClassInText4.setFont(new java.awt.Font("宋體", Font.PLAIN, 16));
ClassInText4.setBounds(new Rectangle(107, 320, 104, 22));
ClassInOK.setBounds(new Rectangle(319, 252, 81, 23));
ClassInOK.setText("OK");
jButton3.setBounds(new Rectangle(0, 0, 81, 23));
jButton3.setText("jButton3");
SaveOK.setBounds(new Rectangle(289, 12, 81, 23));
SaveOK.setText("保存");
studentInput.setLayout(null);
scoreIn.setLayout(null);
search.setLayout(null);
jLabel5.setFont(new java.awt.Font("宋體", Font.BOLD, 18));
jLabel5.setText("選擇班級");
jLabel5.setBounds(new Rectangle(9, 18, 123, 26));
StuInBox.setBounds(new Rectangle(9, 53, 181, 21));
StuInBox.addItem(null);
StuInOk.setBounds(new Rectangle(9, 109, 81, 23));
StuInOk.setText("OK");
ScoreInOK.setBounds(new Rectangle(7, 294, 81, 23));
ScoreInOK.setText("確定");
jLabel6.setFont(new java.awt.Font("宋體", Font.BOLD, 18));
jLabel6.setText("選擇班級");
jLabel6.setBounds(new Rectangle(7, 11, 153, 26));
ScoreInBox1.setBounds(new Rectangle(7, 44, 149, 24));
ScoreInBox1.addItem(null);
ScoreInBox2.addItem(null);
ScoreInBox2.addItem("新增課程");
SearchBox1.setBounds(new Rectangle(85, 4, 333, 23));
SearchBox1.addItem(null);
jLabel7.setFont(new java.awt.Font("宋體", Font.BOLD, 18));
jLabel7.setText("選擇班級");
jLabel7.setBounds(new Rectangle(2, 2, 138, 25));
jTabbedPane2.setBounds(new Rectangle(0, 62, 450, 328));
jPanel1.setBounds(new Rectangle(0, 0, 10, 10));
jPanel3.setBounds(new Rectangle(0, 0, 10, 10));
SearchBox2.setBounds(new Rectangle(85, 32, 167, 23));
SearchBox2.addItem(null);
科目.setFont(new java.awt.Font("宋體", Font.BOLD, 18));
科目.setText("科目");
科目.setBounds(new Rectangle(42, 34, 62, 18));
jLabel8.setFont(new java.awt.Font("宋體", Font.BOLD, 18));
jLabel8.setText("課程選擇");
jLabel8.setBounds(new Rectangle(7, 74, 86, 24));
ScoreInBox2.setBounds(new Rectangle(7, 101, 146, 21));
jLabel9.setFont(new java.awt.Font("宋體", Font.BOLD, 18));
jLabel9.setText("課程信息");
jLabel9.setBounds(new Rectangle(6, 125, 85, 26));
jScrollPane2.setBounds(new Rectangle(196, 0, 257, 390));
jScrollPane3.setBounds(new Rectangle(157, 0, 293, 390));
jScrollPane4.setBounds(new Rectangle(5, 150, 150, 121));
NumModel.setLayout(null);
jPanel2.setBounds(new Rectangle(0, 0, 10, 10));
LineModel.setLayout(null);
CircleModel.setLayout(null);
ClassDel.setBounds(new Rectangle(9, 156, 81, 23));
ClassDel.setActionCommand("Delete");
ClassDel.setText("Delete");
CourseDel.setBounds(new Rectangle(7, 347, 81, 23));
CourseDel.setActionCommand("Delete");
CourseDel.setText("Delete");
ClassInput.add(jLabel1);
ClassInput.add(ClassInText1);
ClassInput.add(jLabel2);
ClassInput.add(ClassInText2);
ClassInput.add(jLabel3);
ClassInput.add(jLabel4);
ClassInput.add(ClassInText3);
ClassInput.add(ClassInText4);
ClassInput.add(ClassInOK);
ClassInput.add(jScrollPane1);
studentInput.add(jLabel5);
studentInput.add(StuInBox);
studentInput.add(StuInOk);
studentInput.add(jScrollPane2);
studentInput.add(ClassDel);
jScrollPane2.getViewport().add(jTable2);
scoreIn.add(jLabel6);
scoreIn.add(ScoreInBox1);
scoreIn.add(jLabel8);
scoreIn.add(ScoreInBox2);
scoreIn.add(jLabel9);
scoreIn.add(jScrollPane3);
scoreIn.add(jScrollPane4);
scoreIn.add(ScoreInOK);
scoreIn.add(CourseDel);
jScrollPane4.getViewport().add(jTable4);
jScrollPane3.getViewport().add(jTable3);
search.add(jTabbedPane2);
jScrollPane1.getViewport().add(jTable1);
contentPane.add(SaveOK);
contentPane.add(jTabbedPane1, null);
jTabbedPane2.add(NumModel, "成績數字模式");
jTabbedPane2.add(LineModel, "條形模式");
jTabbedPane2.add(CircleModel, "餅圖模式");
search.add(jLabel7);
search.add(SearchBox1);
search.add(SearchBox2);
search.add(科目);
jTabbedPane1.add(ClassInput, "班級錄入");
jTabbedPane1.add(studentInput, "學生錄入");
jTabbedPane1.add(scoreIn, "成績錄入"); //個人數據初始話
jTabbedPane1.add(search, "成績查詢");
this.CourseSys1=data.Load();
if(CourseSys1!=null)
{
//
for (int i = 0; i < this.CourseSys1.getClassNum(); i++) {
String[] add = this.CourseSys1.getMyClass()[i].getClassMes();
model.addRow(add);
StuInBox.addItem(this.CourseSys1.getMyClass()[i].toString());
ScoreInBox1.addItem(this.CourseSys1.getMyClass()[i].toString());
SearchBox1.addItem(this.CourseSys1.getMyClass()[i].toString());
}
//
}
else CourseSys1=new CourseSys();
this.ClassInOK.addActionListener(this);
this.SaveOK.addActionListener(this);
this.StuInBox.addActionListener(this);
this.ScoreInBox1.addActionListener(this);
this.ScoreInBox2.addActionListener(this);
this.SearchBox1.addActionListener(this);
this.SearchBox2.addActionListener(this);
this.StuInOk.addActionListener(this);
this.ScoreInBox1.addActionListener(this);
this.ScoreInBox2.addActionListener(this);
this.ScoreInOK.addActionListener(this);
this.ClassDel.addActionListener(this);
this.CourseDel.addActionListener(this);
}
//事件跟蹤驅動
public void actionPerformed(ActionEvent e){
//增加班級
if(e.getSource()==this.ClassInOK)
{
String b=this.ClassInText1.getText()+"年級"+this.ClassInText2.getText()+this.ClassInText3.getText()+"班";
try
{
if (CourseSys1.findClass(b) == null) {
this.CourseSys1.addClass(this.ClassInText1.getText(),
this.ClassInText2.getText(),
this.ClassInText3.getText(),
this.ClassInText4.getText());
String[] a = {this.ClassInText1.getText(),
this.ClassInText2.getText(),
this.ClassInText3.getText(),
this.ClassInText4.getText()};
model.addRow(a);
StuInBox.addItem(b);
ScoreInBox1.addItem(b);
SearchBox1.addItem(b);
} else
JOptionPane.showMessageDialog(null, "有這個班級了", "課程設計提示",JOptionPane.INFORMATION_MESSAGE);
}
catch(Exception var3)
{
JOptionPane.showMessageDialog(null, "信息不足", "課程設計提示",JOptionPane.INFORMATION_MESSAGE);
}
}
//存儲
else if(e.getSource()==this.SaveOK)
{
try
{
this.data.Save(this.CourseSys1);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -