📄 mainface.java
字号:
/**
* @(#)MainFace.java
*
*
* @author
* @version 1.00 2008/7/4
*/
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;
import java.sql.*;
public class MainFace implements ActionListener,MouseListener{
JFrame mf;
JPanel jpl1,jpl2,jpl3;
JButton btn1,btn2,btn3,btn4,btn5;
JLabel jl;
DataBaseManager db = new DataBaseManager();
ResultSet rs;
JPanel jpa11,jpa12,jpa13,jpa14; //网Card面板里面添加的面板
CardLayout card = new CardLayout ();
//学生信息面板
JLabel jl1,jl2,jl3,jl4,jl5;
JComboBox jcb;
JTextField jt1,jt2,jt4,jt5;
JButton jbtn; //确定信息按钮
//教师面板信息
JLabel tjl1,tjl2,tjl3,tjl4,tjl5;
JComboBox tjcb;
JTextField tjt1,tjt2,tjt3,tjt4,tjt5;
JButton tjbtn;
//浏览学生信息面板信息
JLabel sjl1;
JComboBox sjcb;
JTextField sjtf;
JButton sjbtn;
JTable sjta;
DefaultTableModel model;
static String mainStr;
public MainFace() {
mf = new JFrame();
mf.setSize(500,400);
mf.setLocation(200,150);
mf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jpl1 = new JPanel();
jpl2 = new JPanel();
jpl3 = new JPanel();
ImageIcon im = new ImageIcon("F:/0508010113.JPG");
JButton Ijbtn = new JButton(im);
jpa11 = new JPanel();
jpa11.add(Ijbtn);
//学生信息面板
jl1 = new JLabel("学号");
jl1.setPreferredSize(new Dimension(50,25));
jl2 = new JLabel("姓名");
jl2.setPreferredSize(new Dimension(50,25));
jl3 = new JLabel("性别");
jl3.setPreferredSize(new Dimension(50,25));
jl4 = new JLabel("学院");
jl4.setPreferredSize(new Dimension(50,25));
jl5 = new JLabel("专业");
jl5.setPreferredSize(new Dimension(50,25));
jt1 = new JTextField(14);
jt1.setPreferredSize(new Dimension(50,25));
jt1.setEditable(true);
jt2 = new JTextField(14);
jt2.setPreferredSize(new Dimension(50,25));
jt2.setEditable(true);
String[] strjcb = {"男 ","女"};
jcb = new JComboBox(strjcb);
jt4 = new JTextField(14);
jt4.setPreferredSize(new Dimension(50,25));
jt4.setEditable(true);
jt5 = new JTextField(14);
jt5.setPreferredSize(new Dimension(50,25));
jt5.setEditable(true);
jbtn = new JButton("确定");
jbtn.addActionListener(this);
jpa12 = new JPanel();
jpa12.setSize(240,250);
jpa12.setLayout(new GridLayout(6,1));
JPanel jpa21 = new JPanel();
jpa21.setLayout(new FlowLayout(FlowLayout.CENTER));
jpa21.add(jl1);
jpa21.add(jt1);
JPanel jpa22 = new JPanel();
jpa22.setLayout(new FlowLayout(FlowLayout.CENTER));
jpa22.add(jl2);
jpa22.add(jt2);
JPanel jpa23 = new JPanel();
jpa23.setLayout(new FlowLayout(FlowLayout.CENTER));
jpa23.add(jl3);
jpa23.add(jcb);
JPanel jpa24 = new JPanel();
jpa24.setLayout(new FlowLayout(FlowLayout.CENTER));
jpa24.add(jl4);
jpa24.add(jt4);
JPanel jpa25 = new JPanel();
jpa25.setLayout(new FlowLayout(FlowLayout.CENTER));
jpa25.add(jl5);
jpa25.add(jt5);
JPanel jpa26 = new JPanel();
jpa26.setLayout(new FlowLayout(FlowLayout.CENTER));
jpa26.add(jbtn);
jpa12.add(jpa21);
jpa12.add(jpa22);
jpa12.add(jpa23);
jpa12.add(jpa24);
jpa12.add(jpa25);
jpa12.add(jpa26);
//教师面板信息
tjl1 = new JLabel("工号");
tjl1.setPreferredSize(new Dimension(50,25));
tjl2 = new JLabel("姓名");
tjl2.setPreferredSize(new Dimension(50,25));
tjl3 = new JLabel("性别");
tjl3.setPreferredSize(new Dimension(50,25));
tjl4 = new JLabel("学院");
tjl4.setPreferredSize(new Dimension(50,25));
tjl5 = new JLabel("职称");
tjl5.setPreferredSize(new Dimension(50,25));
tjt1 = new JTextField(14);
tjt1.setPreferredSize(new Dimension(50,25));
tjt1.setEditable(true);
tjt2 = new JTextField(14);
tjt2.setPreferredSize(new Dimension(50,25));
tjt2.setEditable(true);
String[] tstrjcb = {"男 ","女"};
tjcb = new JComboBox(tstrjcb);
tjt4 = new JTextField(14);
tjt4.setPreferredSize(new Dimension(50,25));
tjt4.setEditable(true);
tjt5 = new JTextField(14);
tjt5.setPreferredSize(new Dimension(50,25));
tjt5.setEditable(true);
tjbtn = new JButton("确定");
tjbtn.addActionListener(this);
jpa13 = new JPanel();
jpa13.setSize(240,250);
jpa13.setLayout(new GridLayout(6,1));
JPanel tjpa21 = new JPanel();
tjpa21.setLayout(new FlowLayout(FlowLayout.CENTER));
tjpa21.add(tjl1);
tjpa21.add(tjt1);
JPanel tjpa22 = new JPanel();
tjpa22.setLayout(new FlowLayout(FlowLayout.CENTER));
tjpa22.add(tjl2);
tjpa22.add(tjt2);
JPanel tjpa23 = new JPanel();
tjpa23.setLayout(new FlowLayout(FlowLayout.CENTER));
tjpa23.add(tjl3);
tjpa23.add(tjcb);
JPanel tjpa24 = new JPanel();
tjpa24.setLayout(new FlowLayout(FlowLayout.CENTER));
tjpa24.add(tjl4);
tjpa24.add(tjt4);
JPanel tjpa25 = new JPanel();
tjpa25.setLayout(new FlowLayout(FlowLayout.CENTER));
tjpa25.add(tjl5);
tjpa25.add(tjt5);
JPanel tjpa26 = new JPanel();
tjpa26.setLayout(new FlowLayout(FlowLayout.CENTER));
tjpa26.add(tjbtn);
jpa13.add(tjpa21);
jpa13.add(tjpa22);
jpa13.add(tjpa23);
jpa13.add(tjpa24);
jpa13.add(tjpa25);
jpa13.add(tjpa26);
//浏览学生信息面板信息
sjl1 = new JLabel("查询");
String []strType = {"学号","姓名","院系","专业"};
sjcb = new JComboBox(strType);;
sjtf = new JTextField(10);
sjbtn = new JButton("查询");
sjbtn.addActionListener(this);
Object[][] arrayObj= {};
String[] colum = {"学号","姓名","性别","院系","专业"};
model = new DefaultTableModel(arrayObj,colum);
sjta = new JTable(model);//arrayObj,colum
sjta.setShowGrid(true);
sjta.setPreferredSize(new Dimension(250,230));
sjta.setPreferredScrollableViewportSize(new Dimension(350,250));
JScrollPane scrollPane=new JScrollPane(sjta);
sjta.addMouseListener(this);
jpa14 =new JPanel();
jpa14.setSize(240,250);
//jpa14.setLayout(new GridLayout(2,1));
jpa14.setLayout(new BorderLayout());
JPanel sjpa21 = new JPanel();
sjpa21.setLayout(new FlowLayout(FlowLayout.CENTER));
sjpa21.add(sjl1);
sjpa21.add(sjcb);
sjpa21.add(sjtf);
sjpa21.add(sjbtn);
JPanel sjpa22 = new JPanel();
//sjpa22.setBackground(Color.white);
sjpa22.setLayout(new FlowLayout(FlowLayout.CENTER));
sjpa22.add(scrollPane);
jpa14.add(sjpa21,BorderLayout.NORTH);
jpa14.add(sjpa22,BorderLayout.CENTER);
//主面板信息
jpl1.setLayout(card);
jpl1.add("first",jpa11);
jpl1.add("second",jpa12);
jpl1.add("third",jpa13);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -