📄 dialogforchoose.java
字号:
package E4;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
import java.io.File;
import java.io.*;
import java.util.StringTokenizer;
import javax.swing.table.*;
import java.sql.*;
//查找界面
class dialogForChoose implements ActionListener
{
JDialog jdl;
String id="";
String name = "";
JTextField cno = new JTextField("",9);
JButton confirm = new JButton("确定");//只有在单个学生时才好使
JButton concel = new JButton("取消");
Object course [] = new Object[6];
public static JTable table;
AbstractTableModel tm;
public Vector content = new Vector();
String[] title_name = {"序号","课程号","课程名","所属系","学分","任课教师","学期"};
public static int jishu;
public static JLabel showNum=new JLabel("总数为:"+jishu);
JPanel jpl=new JPanel();
JPanel showDetail = new JPanel();
JButton jAdd=new JButton("批量");
JButton jRefresh=new JButton("刷新");
JButton jSet=new JButton("设置");
JPanel forChoice=new JPanel();
JPanel forAddSouth = new JPanel();
proceeSQL psql= new proceeSQL();
addCourseMuch acm;
SetForChoose sfc;
dialogForChoose(JFrame f,String s,boolean b)
{
jdl = new JDialog(f,s,b);
jdl.setSize(700,450);
jdl.setLocation(350,300);
jdl.setResizable(false);
acm = new addCourseMuch(f,"批量选课",b);
sfc = new SetForChoose(f,"设置课程",b);
jdl.addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{
jdl.setVisible(false);
}});
jishu = psql.SearchCourseDetail(content);
tm = new AbstractTableModel(){
public String getColumnName(int col){return title_name[col];
}
public int getColumnCount(){return title_name.length;}
public int getRowCount(){return content.size();}
public Object getValueAt(int row,int col){return ((Vector)content.get(row)).get(col);}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return true;
}
};
table=new JTable(tm);
forAddSouth.setLayout(new FlowLayout(FlowLayout.RIGHT,6,6));
forAddSouth.add(new JLabel("课序号:"));
forAddSouth.add(cno);
forAddSouth.add(confirm);
forAddSouth.add(concel);
jpl.add(jAdd);
jpl.add(jSet);
jpl.add(jRefresh);
jpl.add(showNum);
jAdd.addActionListener(this);
jSet.addActionListener(this);
concel.addActionListener(this);
sfc.anc.handin.addActionListener(this);
jpl.setLayout(new GridLayout(8,1,2,9));
jdl.add(jpl,BorderLayout.WEST);
jdl.add(new JLabel("选择课程",JLabel.CENTER),BorderLayout.NORTH);
jdl.add(forAddSouth,BorderLayout.SOUTH);
jdl.add(new JScrollPane(table));
}
public void setEnable(boolean set){
if(set){
jAdd.setEnabled(true);
jSet.setEnabled(true);
}
else {
jAdd.setEnabled(false);
jSet.setEnabled(false);
}
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==confirm){
}
else if(e.getSource()==concel){
jdl.setVisible(false);
}
else if(e.getSource()==jAdd){
acm.setDisplay(true);
}
else if(e.getSource()==jSet){
sfc.setDisplay(true);
}
else if(e.getSource()==jRefresh){
reFresh();
}
else if(e.getSource()==sfc.anc.handin){
psql.insertCourseDetail(sfc.anc.course);
reFresh();
}
}
void reFresh(){
table.setVisible(false);
content.removeAllElements();
jishu = psql.SearchCourseDetail(content);
table.setVisible(true);
showNum.setText("总数为:"+jishu);
}
void setIdAndName(String id,String name){
this.id=id;
this.name=name;
}
void setDisplay(Boolean tf){
jdl.setVisible(tf);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -