📄 student.java
字号:
package com.window.student;
import java.awt.Choice;
import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Panel;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
import com.window.login.Login;
import com.window.teacher.Data;
public class Student extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JLabel jLabel1 = null;
private JList jList = null;
private JButton okjButton = null;
private JButton canceljButton = null;
private JLabel jLabel2 = null;
private Choice choice = null;
private JLabel jLabel3 = null;
private Panel choicepanel = null;
private Panel okchoicepanel = null; // @jve:decl-index=0:visual-constraint="-6,762"
private JList okchoicejList1 = null;
private JButton canceljButtonokchocice = null;
private JLabel jLabel4 = null;
private Panel usermanagepanel = null;
private JPasswordField newpasswordjPasswordField = null;
private JPasswordField renewpasswordjPasswordField = null;
private JLabel jLabel5 = null;
private JLabel okpasswordjLabel6 = null;
private JButton usermanageokjButton = null;
private JButton usermanagecanceljButton = null;
private JToolBar jJToolBarBar3 = null;
private JToolBar jJToolBarBar4 = null;
private StudentDatafromDB studentDB=new StudentDatafromDB(); // @jve:decl-index=0:
/**
* This is the default constructor
*/
public Student(String studentname,String studentno) {
super();
studentName=studentname;
studnetNo=studentno;
initialize();
usernNamejLabel2.setText(studentName);
}
private String studentName=null; // @jve:decl-index=0:
private String studnetNo=null; // @jve:decl-index=0:
private Choice liefNochoice = null;
private JLabel jLabel6 = null;
private JButton lookCoursejButton = null;
private JToolBar jJToolBarBar5 = null;
private JToolBar jJToolBarBar6 = null;
private JLabel jLabel7 = null;
private JMenuBar tooljJMenuBar = null;
private JMenu tooljMenu = null;
private JMenu choiceCourseMangerjMenu = null;
private JMenu chengjiMangerjMenu = null;
private JMenu helpjMenu = null;
private JMenu userMangerjMenu = null;
private Data data = null;
private Data data1 = null;
private JButton temp1 = null;
private JToolBar jToolBar1 = null;
private JLabel jLabel14 = null;
private JLabel usernNamejLabel2 = null;
private JMenuItem exitjMenuItem = null;
private JMenuItem chiceCoursejMenuItem = null;
private JMenuItem okchoiceCoursejMenuItem = null;
private JMenuItem userjMenuItem = null;
private JButton toChoiceCoursejButton = null;
private JButton chengjijButton = null;
private JButton userjButton = null;
private JButton helpjButton = null;
private JPanel jPanel = null;
private JMenuItem startpaneljMenuItem = null;
private JMenuItem chengjijMenuItem = null;
private Panel chengjipanel = null; // @jve:decl-index=0:visual-constraint="-4,1606"
private JLabel jLabel9 = null;
private JToolBar jJToolBarBar31 = null;
private Choice chengjichoice = null;
private JLabel jLabel31 = null;
private JList chengjijList = null;
private JScrollPane chengjijScrollPane = null;
private JButton lookchengjijButton = null;
private JLabel jLabel10 = null;
private JLabel jLabel11 = null;
private JLabel jLabel12 = null;
private JLabel jLabel13 = null;
private JLabel jLabel15 = null;
private JButton zhuxiaojButton = null;
private JButton jButton = null;
private JMenuItem zhuxiaojMenuItem = null;
private JLabel jLabel = null;
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(764, 481);
this.setContentPane(getJContentPane());
this.setJMenuBar(getTooljJMenuBar());
this.setForeground(Color.black);
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
this.setBounds((screenSize.width-this.getWidth())/2,(screenSize.height-this.getHeight())/2,this.getWidth(), this.getHeight());
this.setTitle("学生选课系统");
//this.add(getJContentPane());
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel15 = new JLabel();
jLabel15.setBounds(new Rectangle(1, 34, 753, 373));
jLabel15.setIcon(new ImageIcon(getClass().getResource("/image/main.gif")));
jLabel15.setText("JLabel");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(-1, 2, 759, 33));
jLabel1.setIcon(new ImageIcon(getClass().getResource("/image/QQ\u622a\u56fe\u672a\u547d\u540d1.gif")));
jLabel1.setComponentOrientation(ComponentOrientation.UNKNOWN);
jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel1.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 18));
jLabel1.setText("欢迎使用学生选课系统");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabel1, null);
jContentPane.add(getJToolBar1(), null);
jContentPane.add(getJPanel(), null);
jContentPane.add(jLabel15, null);
}
return jContentPane;
}
/**
* This method initializes jList
*
* @return javax.swing.JList
*/
private JList getJList() {
if (jList == null) {
jList = new JList();
jList.setBounds(new Rectangle(1, 28, 746, 279));
jList.setCellRenderer(new CheckBoxItem());
jList.setVisible(true);
//addDatafromDB studentDB=new addDatafromDB();
//jList.setListData(studentDB.readdatafromChoice());
}
return jList;
}
/**
* This method initializes okjButton
*
* @return javax.swing.JButton
*/
private JButton getOkjButton() {
if (okjButton == null) {
okjButton = new JButton();
okjButton.setText("选择");
okjButton.setBounds(new Rectangle(529, 320, 61, 20));
okjButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
if(!jList.isSelectionEmpty())
{
String str=(String)jList.getSelectedValue();
int i=str.indexOf(" ");
str=str.substring(0, i);
studentDB.insertData(studnetNo, str, liefNochoice.getSelectedItem());
}
}
// TODO Auto-generated Event stub actionPerformed()
});
}
return okjButton;
}
/**
* This method initializes canceljButton
*
* @return javax.swing.JButton
*/
private JButton getCanceljButton() {
if (canceljButton == null) {
canceljButton = new JButton();
canceljButton.setText("取消");
canceljButton.setBounds(new Rectangle(598, 319, 65, 21));
}
return canceljButton;
}
/**
* This method initializes choice
*
* @return java.awt.Choice
*/
private Choice getChoice() {
if (choice == null) {
choice = new Choice();
choice.setBounds(new Rectangle(586, 1, 116, 15));
choice.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
if(!choice.getSelectedItem().trim().equals(" "))
{
jList.setListData(studentDB.readdCourse(choice.getSelectedItem()));
}
}
});
String item1[]={"","人文类","科技类","全部"};
for(int i=0;i<item1.length;i++)
{
choice.addItem(item1[i]);
}
}
return choice;
}
/**
* This method initializes choicepanel
*
* @return java.awt.Panel
*/
private Panel getChoicepanel() {
if (choicepanel == null) {
jLabel6 = new JLabel();
jLabel6.setBounds(new Rectangle(266, 313, 54, 18));
jLabel6.setText("自愿号");
jLabel3 = new JLabel();
jLabel3.setText("类型");
jLabel3.setBounds(new Rectangle(708, 5, 38, 18));
jLabel2 = new JLabel();
jLabel2.setText("可选课程列表");
jLabel2.setBounds(new Rectangle(323, 1, 94, 18));
choicepanel = new Panel();
choicepanel.setLayout(null);
choicepanel.setEnabled(true);
choicepanel.setVisible(true);
choicepanel.setBounds(new Rectangle(3, 36, 749, 368));;
choicepanel.add(getJList(), null);
choicepanel.add(getChoice(), null);
choicepanel.add(jLabel3, null);
choicepanel.add(jLabel2, null);
choicepanel.add(getOkjButton(), null);
choicepanel.add(getCanceljButton(), null);
choicepanel.add(getJJToolBarBar3(), null);
choicepanel.add(getJJToolBarBar4(), null);
choicepanel.add(getLiefNochoice(), null);
choicepanel.add(jLabel6, null);
}
return choicepanel;
}
/**
* This method initializes okchoicepanel
*
* @return java.awt.Panel
*/
private Panel getOkchoicepanel() {
if (okchoicepanel == null) {
jLabel4 = new JLabel();
jLabel4.setBounds(new Rectangle(339, 8, 84, 18));
jLabel4.setText("初选课程列表");
okchoicepanel = new Panel();
okchoicepanel.setLayout(null);
okchoicepanel.setVisible(true);
okchoicepanel.setBounds(new Rectangle(3, 36, 749, 368));
okchoicepanel.add(getOkchoicejList1(), null);
okchoicepanel.add(getCanceljButtonokchocice(), null);
okchoicepanel.add(jLabel4, null);
okchoicepanel.add(getLookCoursejButton(), null);
okchoicepanel.add(getJJToolBarBar5(), null);
okchoicepanel.add(getJJToolBarBar6(), null);
}
return okchoicepanel;
}
/**
* This method initializes okchoicejList1
*
* @return javax.swing.JList
*/
private JList getOkchoicejList1() {
if (okchoicejList1 == null) {
okchoicejList1 = new JList();
okchoicejList1.setBounds(new Rectangle(3, 35, 744, 282));
okchoicejList1.setCellRenderer(new CheckBoxItem());
}
return okchoicejList1;
}
/**
* This method initializes canceljButtonokchocice
*
* @return javax.swing.JButton
*/
private JButton getCanceljButtonokchocice() {
if (canceljButtonokchocice == null) {
canceljButtonokchocice = new JButton();
canceljButtonokchocice.setBounds(new Rectangle(631, 331, 93, 22));
canceljButtonokchocice.setText("取消选课");
canceljButtonokchocice.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
if(!okchoicejList1.isSelectionEmpty())
{
String str=(String)okchoicejList1.getSelectedValue();
int i=str.indexOf(" ");
str=str.substring(0, i);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -