📄 guest.java
字号:
//Label("考试成绩");
gradeGbc.gridx=0;gradeGbc.gridwidth=1;
gradeGbc.gridy=9;gradeGbc.gridheight=1;
gradeGbc.anchor=GridBagConstraints.WEST;
gradePane.add(label30,gradeGbc);
//text("考试成绩")
gradeGbc.gridx=1;gradeGbc.gridwidth=1;
gradeGbc.gridy=9;gradeGbc.gridheight=1;
gradeGbc.anchor=GridBagConstraints.WEST;
gradePane.add(text30,gradeGbc);
//
gradeGbc.gridx=1;gradeGbc.gridwidth=1;
gradeGbc.gridy=11;gradeGbc.gridheight=1;
gradeGbc.anchor=GridBagConstraints.WEST;
gradePane.add(spaceLabel8,gradeGbc);
//Label("课程简介");
gradeGbc.gridx=0;gradeGbc.gridwidth=1;
gradeGbc.gridy=12;gradeGbc.gridheight=1;
gradeGbc.anchor=GridBagConstraints.WEST;
gradePane.add(label31,gradeGbc);
//text("课程简介")
gradeGbc.gridx=1;gradeGbc.gridwidth=7;
gradeGbc.gridy=12;gradeGbc.gridheight=3;
gradeGbc.anchor=GridBagConstraints.WEST;
gradePane.add(scrPane2,gradeGbc);
basicGradePane.add(gradePane,BorderLayout.CENTER);
//数据操作窗体workPane
JPanel workPane=new JPanel();
ImageIcon next=new ImageIcon("images/next.gif");
nextButton=new JButton("下一条",next);
nextButton.addActionListener(this);
ImageIcon previous=new ImageIcon("images/previous.gif");
previousButton=new JButton("上一条",previous);
previousButton.addActionListener(this);
ImageIcon add=new ImageIcon("images/add.gif");
addButton=new JButton("添 加",add);
addButton.addActionListener(this);
ImageIcon del=new ImageIcon("images/del.gif");
delButton=new JButton("删 除",del);
delButton.addActionListener(this);
ImageIcon update=new ImageIcon("images/update.gif");
updateButton=new JButton("更 新",update);
updateButton.addActionListener(this);
ImageIcon clean=new ImageIcon("images/clean.gif");
cleanButton=new JButton("清 空",clean);
cleanButton.addActionListener(this);
Border workPaneEtched=BorderFactory.createEtchedBorder();
Border workPaneTitled=BorderFactory.createTitledBorder(workPaneEtched,"信息查询");
workPane.setBorder(workPaneTitled);
BorderLayout workPane_Layout=new BorderLayout();
workPane.setLayout(workPane_Layout);
queryDataComboBox=new JComboBox(queryDataName);
queryGradeComboBox=new JComboBox(queryGradeName);
dataNameComboBox=new JComboBox(DataName);
gradeNameComboBox=new JComboBox(GradeName);
queryDataComboBox.addActionListener(this);
queryGradeComboBox.addActionListener(this);
dataComboBox=new JComboBox(Data);
gradeComboBox=new JComboBox(Grade);
gradeComboBox.addActionListener(this);
queryGradeComboBox.addActionListener(this);
JLabel queryLabel1=new JLabel("选择查询的字段");
JLabel queryLabel2=new JLabel("请选择匹配的值");
JLabel L1=new JLabel("----------------------------------------------------------------");
JLabel L2=new JLabel("----------------------------------------------------------------");
JLabel L3=new JLabel("----------------------------------------------------------------");
queryText=new JTextField("",7);
JLabel queryDataLabel=new JLabel("选择字段名");
JLabel queryGradeLabel=new JLabel("选择字段");
queryLabel1.setFont(new Font("宋体", Font.BOLD ,16));
queryLabel2.setFont(new Font("宋体", Font.BOLD ,16));
//简单查询simplenessSelectPane
selectLabel=new JLabel("选择查询的单项");
selectLabel2=new JLabel("");
selectLabel3=new JLabel("");
selectLabel.setFont(new Font("宋体", Font.BOLD ,16));
simplenessSelectPane=new JPanel();
GridBagLayout simplenessSelectPane_Layout=new GridBagLayout();
simplenessSelectPane.setLayout(simplenessSelectPane_Layout);
sSelectGbc=new GridBagConstraints();
sSelectGbc.gridx=2;sSelectGbc.gridwidth=2;
sSelectGbc.gridy=2;sSelectGbc.gridheight=2;
sSelectGbc.anchor=GridBagConstraints.WEST;
//sSelectGbc.fill=GridBagConstraints.NONE;
simplenessSelectPane.add(queryLabel1,sSelectGbc);
sSelectGbc.gridx=4;sSelectGbc.gridwidth=1;
sSelectGbc.gridy=2;sSelectGbc.gridheight=1;
sSelectGbc.anchor=GridBagConstraints.WEST;
simplenessSelectPane.add(queryDataComboBox,sSelectGbc);
sSelectGbc.gridx=4;sSelectGbc.gridwidth=1;
sSelectGbc.gridy=2;sSelectGbc.gridheight=1;
sSelectGbc.anchor=GridBagConstraints.WEST;
//simplenessSelectPane.add(queryGradeComboBox,sSelectGbc);
sSelectGbc.gridx=2;sSelectGbc.gridwidth=2;
sSelectGbc.gridy=4;sSelectGbc.gridheight=2;
sSelectGbc.anchor=GridBagConstraints.WEST;
simplenessSelectPane.add(queryLabel2,sSelectGbc);
sSelectGbc.gridx=4;sSelectGbc.gridwidth=2;
sSelectGbc.gridy=4;sSelectGbc.gridheight=2;
sSelectGbc.anchor=GridBagConstraints.WEST;
simplenessSelectPane.add(queryText,sSelectGbc);
sSelectGbc.gridx=1;sSelectGbc.gridwidth=5;
sSelectGbc.gridy=12;sSelectGbc.gridheight=1;
sSelectGbc.anchor=GridBagConstraints.WEST;
simplenessSelectPane.add(L1,sSelectGbc);
selectRadioButton=new JRadioButton("高级查询");
selectRadioButton.setFont(new Font("宋体", Font.BOLD ,16));
selectRadioButton.addActionListener(this);
sSelectGbc.gridx=2;sSelectGbc.gridwidth=1;
sSelectGbc.gridy=14;sSelectGbc.gridheight=2;
sSelectGbc.anchor=GridBagConstraints.WEST;
simplenessSelectPane.add(selectLabel2,sSelectGbc);
sSelectGbc.gridx=2;sSelectGbc.gridwidth=1;
sSelectGbc.gridy=18;sSelectGbc.gridheight=2;
sSelectGbc.anchor=GridBagConstraints.WEST;
simplenessSelectPane.add(selectLabel3,sSelectGbc);
//getItemString1=(String)queryDataComboBox.getSelectedItem();
sSelectGbc.gridx=1;sSelectGbc.gridwidth=5;
sSelectGbc.gridy=22;sSelectGbc.gridheight=1;
sSelectGbc.anchor=GridBagConstraints.WEST;
simplenessSelectPane.add(L2,sSelectGbc);
sSelectGbc.gridx=3;sSelectGbc.gridwidth=1;
sSelectGbc.gridy=24;sSelectGbc.gridheight=2;
sSelectGbc.anchor=GridBagConstraints.WEST;
simplenessSelectPane.add(selectButton,sSelectGbc);
sSelectGbc.gridx=1;sSelectGbc.gridwidth=5;
sSelectGbc.gridy=26;sSelectGbc.gridheight=1;
sSelectGbc.anchor=GridBagConstraints.WEST;
simplenessSelectPane.add(L3,sSelectGbc);
sSelectGbc.gridx=2;sSelectGbc.gridwidth=1;
sSelectGbc.gridy=28;sSelectGbc.gridheight=2;
sSelectGbc.anchor=GridBagConstraints.WEST;
simplenessSelectPane.add(previousButton,sSelectGbc);
sSelectGbc.gridx=4;sSelectGbc.gridwidth=1;
sSelectGbc.gridy=28;sSelectGbc.gridheight=2;
sSelectGbc.anchor=GridBagConstraints.EAST;
simplenessSelectPane.add(nextButton,sSelectGbc);
// getItemString=(String)queryDataComboBox.getSelectedItem();
//详细查询particularSelectPane
particularSelectPane=new JPanel();
workPane.add(simplenessSelectPane,"North");
/*JPanel doPane=new JPanel();
doPane.setLayout(new FlowLayout(FlowLayout.CENTER,15,15));
doPane.add(addButton);doPane.add(delButton);
doPane.add(cleanButton);doPane.add(updateButton);
workPane.add(doPane,"Center");*/
JPanel exitPane=new JPanel();
exitPane.setLayout(new FlowLayout(FlowLayout.CENTER,15,15));
exitPane.add(loginButton);
exitPane.add(exitButton);
workPane.add(exitPane,"South");
//JPanel data1_selectPane=new JPanel();
//Border data1_selectEtched=BorderFactory.createEtchedBorder();
//Border data1_selectTitled=BorderFactory.createTitledBorder(data1_selectEtched,"选择数据库");
//data1_selectPane.setBorder(data1_selectTitled);
//data1_selectPane.add(ra1Button);
//data1_selectPane.add(ra2Button);
// JPanel data2_selectPane=new JPanel();
// Border etched4=BorderFactory.createEtchedBorder();
// Border titled4=BorderFactory.createTitledBorder(etched4,"选择字段名");
// data2_selectPane.setBorder(titled4);
//data2_selectPane.add(ra3Button);
///JPanel data3_selectPane=new JPanel();
//Border etched5=BorderFactory.createEtchedBorder();
//Border titled5=BorderFactory.createTitledBorder(etched5,"选择查询条件");
//data3_selectPane.setBorder(titled5);
//data3_selectPane.add(text13);
//selectPane.add(data1_selectPane);
//selectPane.add(data2_selectPane);
//selectPane.add(data3_selectPane);
//selectPane.add(selectButton);
//selectPane.add(loginButton);
//selectPane.add(exitButton);
//ra1Button.addItemListener(this);
//ra2Button.addItemListener(this);
//ra3Button.addItemListener(this);
//ra4Button.addItemListener(this);
//信息提示框taPane
JPanel taPane=new JPanel();
Border clewEtched=BorderFactory.createEtchedBorder();
Border clewTitled=BorderFactory.createTitledBorder(clewEtched,"信息提示框");
taPane.setBorder(clewTitled);
taPane.add(clewLabel);
//数据表格窗体dataTablePane
dataTablePane=new JPanel();
BorderLayout dataTablePane_Layout=new BorderLayout();
dataTablePane.setLayout(dataTablePane_Layout);
/*try {
stmt = con.createStatement();
String query = "SELECT * FROM dataTab" ;
rs = stmt.executeQuery(query);
model = new CachingResultSetTableModel(rs);
JTable table = new JTable(model);
scrollTablePane = new JScrollPane(table);
dataTablePane.add(scrollTablePane, "Center");
}
catch(SQLException e)
{ System.out.println("Error " + e);
}*/
//成绩表格窗体gradeTablePane
gradeTablePane=new JPanel();
BorderLayout gradeTablePane_Layout=new BorderLayout();
gradeTablePane.setLayout(gradeTablePane_Layout);
/*try {
Statement stmt = con.createStatement();
String query = "SELECT * FROM gradeTab" ;
ResultSet rs = stmt.executeQuery(query);
ResultSetTableModel model = new CachingResultSetTableModel(rs);
JTable table = new JTable(model);
scrollTablePane = new JScrollPane(table);
gradeTablePane.add(scrollTablePane, "Center");
}
catch(SQLException e)
{ System.out.println("Error " + e);
}*/
tabbedPane.addTab("学生数据",icon1,basicDataPane);
tabbedPane.addTab("学生成绩",icon2,basicGradePane);
tabbedPane.addTab("数据表格", icon, dataTablePane);
tabbedPane.addTab("成绩表格" , icon, gradeTablePane);
//主窗体
getContentPane().add(tabbedPane,"West");
getContentPane().add(workPane,"Center");
getContentPane().add(taPane,"South");
getContentPane().add(bar,"North");
getContentPane().addMouseListener(new MouseAdapter()
{ public void mouseReleased(MouseEvent evt)
{ if (evt.isPopupTrigger())
popup.show(evt.getComponent(),
evt.getX(), evt.getY());
}
});
}
public static void main(String[] args) {
JFrame frame = new guest();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent evt) //鼠标点击事件
{Object source=evt.getSource();
text=(String)queryText.getText();
String arg = evt.getActionCommand(); //菜单点击事件
if(arg.equals("退出(X)"))
{if (JOptionPane.showConfirmDialog(this,
"你确认要退出程序吗?",
"数据查询系统", JOptionPane.YES_NO_OPTION )
== JOptionPane.YES_OPTION)
System.exit(0);
}
if(arg.equals("剪切"))
{queryText.cut();}
if(arg.equals("复制"))
{queryText.paste();}
if(arg.equals("粘贴"))
{queryText.copy();}
if(arg.equals("帮助索引 (I)"))
{}
if(arg.equals("关于软件 (A)"))
{if(aboutDialog==null)
aboutDialog=new AboutDialog(this);
aboutDialog.show();
}
if(source==loginButton)
{ dispose();
JFrame f2=new Login();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -