searchforcourse.java
来自「学生学籍管理系统」· Java 代码 · 共 464 行
JAVA
464 行
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 SearchForCourse implements ActionListener
{
JDialog jfm;
JTabbedPane jplForFrame=new JTabbedPane();
JLabel tell=new JLabel("查找课程信息",JLabel.CENTER);
panelForSearchId_2 pfsi;
panelForSearchName_2 pfsn;
panelForSearchCourseNo_2 pfscn;
panelForSearchCourseName_2 pfsCourseName;
panelForSearchClass_2 pfscla;
panelForSearchCollege_2 pfsco;
SearchForCourse(JFrame f,String s,boolean b)
{
jfm=new JDialog(f,s,b);
jfm.setSize(370,220);
jfm.setBackground(Color.white);
pfsi= new panelForSearchId_2(f,b);
pfsn= new panelForSearchName_2(f,b);
pfscn = new panelForSearchCourseNo_2(f,b);
pfsCourseName = new panelForSearchCourseName_2(f,b);
pfscla= new panelForSearchClass_2(f,b);
pfsco= new panelForSearchCollege_2(f,b);
jfm.addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{
jfm.setVisible(false);
}});
jfm.setResizable(false);
jplForFrame.setBackground(Color.white);
jplForFrame.addTab("学号",pfsi);
jplForFrame.addTab("姓名",pfsn);
jplForFrame.addTab("课程名",pfscn);
jplForFrame.addTab("课程号",pfsCourseName);
jplForFrame.addTab("院系",pfsco);
jplForFrame.addTab("班级",pfscla);
pfsi.cancel.addActionListener(this);
pfsn.cancel.addActionListener(this);
pfscn.cancel.addActionListener(this);
pfsCourseName.cancel.addActionListener(this);
pfsco.cancel.addActionListener(this);
pfscla.cancel.addActionListener(this);
jfm.setLayout(new BorderLayout(9,9));
jfm.add(jplForFrame);
tell.setBackground(Color.BLACK);
jfm.add(tell,BorderLayout.NORTH);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==pfsi.cancel){
this.setDisplay(false);
}
else if(e.getSource()==pfsn.cancel){
this.setDisplay(false);
}
else if(e.getSource()==pfscn.cancel){
this.setDisplay(false);
}
else if(e.getSource()==pfsCourseName.cancel){
this.setDisplay(false);
}
else if(e.getSource()==pfsco.cancel){
this.setDisplay(false);
}
else if(e.getSource()==pfscla.cancel){
this.setDisplay(false);
}
}
void setDisplay(Boolean tf){
jfm.setVisible(tf);
}
}
class panelForSearchId_2 extends JPanel implements ActionListener
{
// framForSearch ffs;//查找界面
JPanel contentPane_1,contentPane_3;
JLabel du_id=new JLabel("输入学号",JLabel.CENTER);
JTextField jf_id=new JTextField("",8);
JButton handin = new JButton("提交");
JButton cancel = new JButton("退出");
proceeSQL psql=new proceeSQL();
panelForSearchId_2(JFrame f,boolean b){
// ffs = new framForSearch(f,"查找用户信息",b);
contentPane_1=new JPanel();
contentPane_3=new JPanel();
contentPane_1.setLayout(new FlowLayout(FlowLayout.CENTER,10,10));
contentPane_1.add(du_id);
contentPane_1.add(jf_id);
contentPane_3.setLayout(new FlowLayout(FlowLayout.CENTER));
contentPane_3.add(handin);
contentPane_3.add(cancel);
cancel.addActionListener(this);
super.setLayout(new BorderLayout(9,9));
super.add(new JLabel("按学号查找",JLabel.CENTER),BorderLayout.NORTH);
super.add(contentPane_1);
super.add(contentPane_3,BorderLayout.SOUTH);;
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==cancel){
}
}
}
class panelForSearchName_2 extends JPanel implements ActionListener
{
// framForSearch ffs;//查找界面
JPanel contentPane_1,contentPane_3;
JLabel du_id=new JLabel("输入姓名",JLabel.CENTER);
JTextField jf_id=new JTextField("",8);
JButton handin = new JButton("提交");
JButton find =new JButton("查找");
JButton cancel = new JButton("退出");
proceeSQL psql=new proceeSQL();
panelForSearchName_2(JFrame f,boolean b){
contentPane_1=new JPanel();
contentPane_3=new JPanel();
contentPane_1.setLayout(new FlowLayout(FlowLayout.CENTER,10,10));
contentPane_1.add(du_id);
contentPane_1.add(jf_id);
contentPane_3.setLayout(new FlowLayout(FlowLayout.CENTER));
contentPane_3.add(handin);
contentPane_3.add(cancel);
cancel.addActionListener(this);
super.setLayout(new BorderLayout(9,9));
super.add(new JLabel("按姓名查找",JLabel.CENTER),BorderLayout.NORTH);
super.add(contentPane_1);
super.add(contentPane_3,BorderLayout.SOUTH);;
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==cancel){
}
}
}
class panelForSearchCourseNo_2 extends JPanel implements ActionListener
{
// framForSearch ffs;//查找界面
JPanel contentPane_1,contentPane_3;
JLabel du_id=new JLabel("输入课程号",JLabel.CENTER);
JTextField jf_id=new JTextField("",8);
JButton handin = new JButton("提交");
JButton cancel = new JButton("退出");
proceeSQL psql=new proceeSQL();
panelForSearchCourseNo_2(JFrame f,boolean b){
// ffs = new framForSearch(f,"查找用户信息",b);
contentPane_1=new JPanel();
contentPane_3=new JPanel();
contentPane_1.setLayout(new FlowLayout(FlowLayout.CENTER,10,10));
contentPane_1.add(du_id);
contentPane_1.add(jf_id);
contentPane_3.setLayout(new FlowLayout(FlowLayout.CENTER));
contentPane_3.add(handin);
contentPane_3.add(cancel);
cancel.addActionListener(this);
super.setLayout(new BorderLayout(9,9));
super.add(new JLabel("按课程号查找",JLabel.CENTER),BorderLayout.NORTH);
super.add(contentPane_1);
super.add(contentPane_3,BorderLayout.SOUTH);;
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==cancel){
}
}
}
class panelForSearchCourseName_2 extends JPanel implements ActionListener
{
// framForSearch ffs;//查找界面
JPanel contentPane_1,contentPane_3;
JLabel du_id=new JLabel("输入课程名",JLabel.CENTER);
JTextField jf_id=new JTextField("",8);
JButton handin = new JButton("提交");
JButton cancel = new JButton("退出");
proceeSQL psql=new proceeSQL();
panelForSearchCourseName_2(JFrame f,boolean b){
// ffs = new framForSearch(f,"查找用户信息",b);
contentPane_1=new JPanel();
contentPane_3=new JPanel();
contentPane_1.setLayout(new FlowLayout(FlowLayout.CENTER,10,10));
contentPane_1.add(du_id);
contentPane_1.add(jf_id);
contentPane_3.setLayout(new FlowLayout(FlowLayout.CENTER));
contentPane_3.add(handin);
contentPane_3.add(cancel);
cancel.addActionListener(this);
super.setLayout(new BorderLayout(9,9));
super.add(new JLabel("按课程名查找",JLabel.CENTER),BorderLayout.NORTH);
super.add(contentPane_1);
super.add(contentPane_3,BorderLayout.SOUTH);;
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==cancel){
}
}
}
class panelForSearchClass_2 extends JPanel implements ActionListener,ItemListener
{
// framForSearch ffs;//查找界面
JPanel contentPane_1,contentPane_3;
Choice college = new Choice();
Choice classes = new Choice();
JButton handin = new JButton("提交");
JButton cancel = new JButton("退出");
proceeSQL psql=new proceeSQL();
panelForSearchClass_2(JFrame f,boolean b){
// ffs = new framForSearch(f,"查找用户信息",b);
contentPane_1=new JPanel();
contentPane_3=new JPanel();
//计算机科学与技术,网络工程,软件工程,会计学,国际贸易,光电子,机械自动化,环境工程
college.addItem("计算机科学与技术");
college.addItem("网络工程");
college.addItem("软件工程");
college.addItem("会计学");
college.addItem("国际贸易");
college.addItem("光电子");
college.addItem("机械自动化");
college.addItem("环境工程");
for(int i=3;i<7;i++)
for(int j=0;j<4;j++)
classes.addItem("计算机科学与技术0"+i+(j+1)+"班");
contentPane_1.add(new JLabel("选择院系:",JLabel.CENTER));
contentPane_1.add(college);
contentPane_1.add(new JLabel("选择班级:",JLabel.CENTER));
contentPane_1.add(classes);
contentPane_1.setLayout(new GridLayout(2,2,9,9));
//college.addItemListener(this);
// classes.addItemListener(this);
contentPane_3.setLayout(new FlowLayout(FlowLayout.CENTER));
contentPane_3.add(handin);
contentPane_3.add(cancel);
//handin.addActionListener(this);
cancel.addActionListener(this);
college.addItemListener(this);
super.setLayout(new BorderLayout(9,9));
super.add(new JLabel("按班级查找",JLabel.CENTER),BorderLayout.NORTH);
super.add(contentPane_1);
super.add(contentPane_3,BorderLayout.SOUTH);;
}
void addIntoClasses(String college){
classes.removeAll();
for(int i=3;i<7;i++)
for(int j=0;j<4;j++)
classes.addItem(college+"0"+i+(j+1)+"班");
}
public void itemStateChanged(ItemEvent e){
if(e.getItemSelectable()==college){
addIntoClasses(college.getSelectedItem());
}
else if(e.getItemSelectable()==classes){
}
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==cancel){
}
else if(e.getSource()==handin){
psql.DistroyStuInforByClasses(classes.getSelectedItem());
}
}
}
class panelForSearchCollege_2 extends JPanel implements ActionListener,ItemListener
{
// framForSearch ffs;//查找界面
JPanel contentPane_1,contentPane_3;
Choice college = new Choice();
JButton handin = new JButton("提交");
JButton cancel = new JButton("退出");
proceeSQL psql=new proceeSQL();
panelForSearchCollege_2(JFrame f,boolean b){
// ffs = new framForSearch(f,"查找用户信息",b);
contentPane_1=new JPanel();
contentPane_3=new JPanel();
college.addItem("计算机科学与技术");
college.addItem("网络工程");
college.addItem("软件工程");
college.addItem("会计学");
college.addItem("国际贸易");
college.addItem("光电子");
college.addItem("机械自动化");
college.addItem("环境工程");
contentPane_1.setLayout(new FlowLayout(FlowLayout.CENTER,10,10));
contentPane_1.add(new JLabel("选择院系:",JLabel.CENTER));
contentPane_1.add(college);
college.addItemListener(this);
contentPane_3.setLayout(new FlowLayout(FlowLayout.CENTER));
contentPane_3.add(handin);
contentPane_3.add(cancel);
// handin.addActionListener(this);
cancel.addActionListener(this);
super.setLayout(new BorderLayout(9,9));
super.add(new JLabel("按院系查找",JLabel.CENTER),BorderLayout.NORTH);
super.add(contentPane_1);
super.add(contentPane_3,BorderLayout.SOUTH);;
}
public void itemStateChanged(ItemEvent e){
if(e.getItemSelectable()==college){
}
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==cancel){
}
else if(e.getSource()==handin){
psql.DistroyStuInforByCollege(college.getSelectedItem());
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?