回 帖 发 新 帖 刷新版面

主题:请高手帮忙看看为什么界面出现不了


本来这个是登陆成功后跳转后的界面,现在连界面都出现不了,哪里出错了
package client;
import java.awt.*;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.table.DefaultTableModel;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Vector;
import com.sun.org.apache.xpath.internal.operations.Bool;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import java.io.*;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;

public class MainFace_User extends JFrame implements ListSelectionListener{
    public MainFace_User(String title) {
        super(title);
        try {
            jbInit();
            this.setBounds(200,200,735,615);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            ///////////////////////////////////////////////////////////////////////////习题管理部分///////////////////////////////////////////////////////
                       Text_Type1.addItem("");//0
                       Text_Type1.addItem("选择题");//1
                       Text_Type1.addItem("填空题");//2
                       Text_Type1.addItem("判断题");//3
                       Text_Type1.addItem("计算题");//4
                       Text_Type1.addItem("简答题");//5
                       Text_Type1.addItem("综合题");//6

                       Text_Difficulty.addItem("");
                       Text_Difficulty.addItem("易");
                       Text_Difficulty.addItem("中");
                       Text_Difficulty.addItem("难");


                       Text_Type2.addItem("");//0
                       Text_Type2.addItem("选择题");//1
                       Text_Type2.addItem("填空题");//2
                       Text_Type2.addItem("判断题");//3
                       Text_Type2.addItem("计算题");//4
                       Text_Type2.addItem("简答题");//5
                       Text_Type2.addItem("综合题");//6

                       //把当前数据库中存在的课程名称放到JP_getCourse1中
                       Vector courseimfor=new Vector();
                       ClientSocket.readCourse(courseimfor);
                       Text_Course.addItem("");
                       count=courseimfor.size();
                       int i=0;
                       for(i=0;i<count;i++){
                           Text_Course.addItem(((Vector)courseimfor.elementAt(i)).elementAt(1).toString());
                       }

                       usercourse=user.getUser_course();

                       String sqlStr = "select * from exercises";
                       ClientSocket.read(sqlStr, StoreText);
                       setcol();
                       model.setDataVector(data1,columnNamanes);
                       TextTable.addMouseListener(
                               new MouseAdapter() {
                                    public void mouseReleased(MouseEvent e)  {
                                         int row=TextTable.getSelectedRow();
                                         if(row<0)return;
                                         Vector ea=new Vector();
                                         preId=TextTable.getValueAt(row,0).toString();  //得到所在行的第一个列的值,作为下面事件传递的参数
                                         for(int i=0;i<StoreText.size();i++){            //取题目的内容
                                             ea=(Vector)StoreText.elementAt(i);
                                             if(ea.elementAt(0).equals(preId)){
                                                 Text_Subject.setText(ea.elementAt(3).toString());
                                                 Text_Key.setText(ea.elementAt(4).toString());
                                                 break;
                                             }
                                         }
                                   }
                               }
                       );
                       Text_Subject.addMouseListener(
                               new MouseAdapter() {
                                    public void mouseReleased(MouseEvent e)  {
                                        Text_Subject.setText("");
                                       }
                                   }
                       );
                       Text_Key.addMouseListener(
                               new MouseAdapter() {
                                    public void mouseReleased(MouseEvent e)  {
                                        Text_Key.setText("");
                                       }
                                   }
                       );
///////////////////////////////////////////////////////////习题管理部分///////////////////////////////////////////////////////


        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

回复列表 (共13个回复)

沙发

private void jbInit() throws Exception {
        getContentPane().setLayout(null);
       this.getContentPane().setBackground(SystemColor.inactiveCaptionText);
        this.addWindowListener(new MainFace_User_this_windowAdapter(this));
        jTabbedPane1.setForeground(SystemColor.textHighlight);
        jTabbedPane1.setBounds(new Rectangle( -1, 68, 760, 519));
        JP_TextMade.setBackground(SystemColor.inactiveCaptionText);
        JP_TextMade.setFont(new java.awt.Font("宋体", Font.BOLD, 20));
        JP_UserInfo.setBackground(UIManager.getColor(
                "InternalFrame.inactiveTitleForeground"));
        JP_UserInfo.setFont(new java.awt.Font("宋体", Font.BOLD, 20));
        jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
        jSplitPane1.setDividerSize(1);
        jSplitPane1.setBounds(new Rectangle(0, 1, 720, 485));
        jPanel1.setLayout(null);
        jPanel2.setLayout(null);
        jLabel1.setBackground(SystemColor.inactiveCaptionText);
        jLabel1.setFont(new java.awt.Font("宋体", Font.BOLD, 18));
        jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel1.setText("用户基本信息");
        jLabel1.setBounds(new Rectangle(220, 0, 296, 32));
        jPanel1.setBackground(SystemColor.inactiveCaptionText);
        jLabel2.setBackground(SystemColor.inactiveCaptionText);
        jLabel2.setFont(new java.awt.Font("宋体", Font.BOLD, 18));
        jLabel2.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel2.setText("修改密码");
        jLabel2.setBounds(new Rectangle(241, 1, 256, 34));
        jPanel2.setBackground(SystemColor.inactiveCaptionText);
        jLabel3.setBackground(SystemColor.inactiveCaptionText);
        jLabel3.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
        jLabel3.setText("用户ID:");
        jLabel3.setBounds(new Rectangle(201, 36, 65, 27));
        jLabel4.setBackground(SystemColor.inactiveCaptionText);
        jLabel4.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
        jLabel4.setText("用户名:");
        jLabel4.setBounds(new Rectangle(200, 66, 67, 28));
        jLabel5.setBackground(SystemColor.inactiveCaptionText);
        jLabel5.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
        jLabel5.setText("所在学院:");
        jLabel5.setBounds(new Rectangle(183, 208, 79, 27));
        jLabel6.setBackground(SystemColor.inactiveCaptionText);
        jLabel6.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
        jLabel6.setText("所教课程:");
        jLabel6.setBounds(new Rectangle(185, 169, 78, 27));
        jLabel7.setBackground(SystemColor.inactiveCaptionText);
        jLabel7.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
        jLabel7.setText("新密码:");
        jLabel7.setBounds(new Rectangle(202, 35, 64, 30));
        jLabel8.setBackground(SystemColor.inactiveCaptionText);
        jLabel8.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
        jLabel8.setText("专   业:");
        jLabel8.setBounds(new Rectangle(192, 101, 72, 24));
        jLabel9.setBackground(SystemColor.inactiveCaptionText);
        jLabel9.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
        jLabel9.setText("职   称:");
        jLabel9.setBounds(new Rectangle(192, 133, 74, 25));
        JP_getUserID1.setBackground(SystemColor.inactiveCaptionText);
        JP_getUserID1.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        JP_getUserID1.setBounds(new Rectangle(265, 37, 256, 26));
        JP_getUserName.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        JP_getUserName.setBounds(new Rectangle(265, 66, 256, 28));
        JP_getDepartment.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        JP_getDepartment.setBounds(new Rectangle(265, 208, 256, 28));
        JP_getProfessor.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        JP_getProfessor.setBounds(new Rectangle(265, 101, 256, 28));
        JP_getLevel.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        JP_getLevel.setBounds(new Rectangle(265, 137, 256, 28));
        B_ChangeUserInfo.setBounds(new Rectangle(327, 263, 100, 23));
        B_ChangeUserInfo.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        B_ChangeUserInfo.setText("修改");
        B_ChangeUserInfo.addActionListener(new
                MainFace_User_B_ChangeUserInfo_actionAdapter(this));
        B_CancelUserInfo.setBounds(new Rectangle(495, 263, 100, 23));
        B_CancelUserInfo.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        B_CancelUserInfo.setText("取消");
        B_CancelUserInfo.addActionListener(new
                MainFace_User_B_CancelUserInfo_actionAdapter(this));
        jLabel12.setBackground(SystemColor.inactiveCaptionText);
        jLabel12.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
        jLabel12.setText("密码确定:");

板凳

jLabel12.setBounds(new Rectangle(187, 74, 83, 25));
        JP_getPassword1.setBounds(new Rectangle(266, 36, 255, 28));
        JP_getPassword2.setBounds(new Rectangle(266, 74, 255, 28));
        B_ChangeUserPa.setBounds(new Rectangle(225, 123, 81, 23));
        B_ChangeUserPa.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        B_ChangeUserPa.setText("修改");
        B_ChangeUserPa.addActionListener(new
                MainFace_User_B_ChangeUserPa_actionAdapter(this));
        B_CancelPa.setBounds(new Rectangle(433, 122, 81, 23));
        B_CancelPa.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        B_CancelPa.setText("取消");
        B_CancelPa.addActionListener(new MainFace_User_B_CancelPa_actionAdapter(this));
        JP_TextControl.setBackground(SystemColor.inactiveCaptionText);
        jLabel11.setBackground(SystemColor.inactiveCaptionText);
        jLabel11.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        jLabel11.setText("题目类型");
        jLabel11.setBounds(new Rectangle(11, 14, 67, 31));
        Text_Type1.setBounds(new Rectangle(72, 16, 76, 24));
        Text_Type1.addActionListener(new MainFace_User_Text_Type1_actionAdapter(this));
        jLabel13.setBackground(SystemColor.inactiveCaptionText);
        jLabel13.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        jLabel13.setText("课程");
        jLabel13.setBounds(new Rectangle(163, 16, 36, 24));
        Text_Course.setBounds(new Rectangle(196, 16, 110, 23));
        Text_Course.addActionListener(new
                                      MainFace_User_Text_Course_actionAdapter(this));
        jLabel14.setBackground(SystemColor.inactiveCaptionText);
        jLabel14.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        jLabel14.setText("章");
        jLabel14.setBounds(new Rectangle(321, 16, 25, 23));
        Chapter.setBounds(new Rectangle(343, 17, 69, 22));
        jLabel15.setBackground(SystemColor.inactiveCaptionText);
        jLabel15.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        jLabel15.setText("类型");
        jLabel15.setBounds(new Rectangle(514, 15, 33, 22));
        Text_Type2.setBounds(new Rectangle(546, 14, 76, 23));
        jLabel16.setBackground(SystemColor.inactiveCaptionText);
        jLabel16.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        jLabel16.setText("难度");
        jLabel16.setBounds(new Rectangle(632, 16, 32, 22));
        Text_Difficulty.setBounds(new Rectangle(662, 15, 48, 21));
        Text_Difficulty.addActionListener(new
                MainFace_User_Text_Difficulty_actionAdapter(this));
        jLabel17.setBackground(SystemColor.inactiveCaptionText);
        jLabel17.setFont(new java.awt.Font("宋体", Font.PLAIN, 14));
        jLabel17.setText("题目");
        jLabel17.setBounds(new Rectangle(207, 47, 43, 28));
        jScrollPane2.setBounds(new Rectangle(207, 74, 488, 201));
        jLabel18.setBackground(SystemColor.inactiveCaptionText);
        jLabel18.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        jLabel18.setText("答案");
        jLabel18.setBounds(new Rectangle(207, 276, 35, 25));
        jScrollPane3.setBounds(new Rectangle(207, 301, 487, 107));
        Text_Subject.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        Text_Subject.setCaretColor(SystemColor.textHighlight);
        Text_Key.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        B_DeteleText.setBounds(new Rectangle(47, 429, 81, 23));
        B_DeteleText.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        B_DeteleText.setText("删除");
        B_DeteleText.addActionListener(new
                                       MainFace_User_B_DeteleText_actionAdapter(this));
        B_AddText.setBounds(new Rectangle(300, 429, 265, 23));
        B_AddText.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
        B_AddText.setText("添加");
        B_AddText.addActionListener(new MainFace_User_B_AddText_actionAdapter(this));
        jLabel20.setBackground(SystemColor.inactiveCaptionText);
        jLabel20.setForeground(SystemColor.inactiveCaptionText);
        jLabel20.setText("");
        jLabel20.setBounds(new Rectangle(0, 1, 725, 71));
        Section.setBounds(new Rectangle(437, 18, 66, 21));
        jLabel19.setText("节");
        jLabel19.setBounds(new Rectangle(422, 16, 29, 22));
        JP_UserInfo.setLayout(null);
        JP_TextMade.setLayout(null);
        JP_TextControl.setLayout(null);
        JP_TextControl.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        js.setBounds(new Rectangle(13, 64, 177, 342));////////////////////////////////////////////
        jButton1.setBounds(new Rectangle(166, 262, 100, 23));
        jButton1.setText("管理员权限");
        jButton1.addActionListener(new MainFace_User_jButton1_actionAdapter(this));
        JP_getCourse.setBounds(new Rectangle(264, 171, 256, 27));

3 楼

yuan_newtest.setBounds(new Rectangle(554, 422, 125, 33));
       yuan_newtest.setText("手动生成试卷");
       yuan_newtest.addActionListener(new MainFace_User_newtest_actionAdapter(this));
       yuam_autonewtest.setBounds(new Rectangle(393, 423, 123, 32));
       yuam_autonewtest.setText("自动生成试卷");
       yuam_autonewtest.addActionListener(new
                                     MainFace_User_autonewtest_actionAdapter(this));
       yuan_jLabel10.setText("浏览试卷:");
       yuan_jLabel10.setBounds(new Rectangle(27, 10, 66, 38));
       yuan_jComboBox1.setBounds(new Rectangle(99, 17, 93, 23));
       yuan_jTextField1.setBounds(new Rectangle(209, 18, 106, 23));
       yuan_jButton2.setBounds(new Rectangle(327, 18, 68, 23));
       yuan_jButton2.setText("查询");
       yuan_jButton2.addActionListener(new MainFace_User_jButton2_actionAdapter(this));
       yuan_jScrollPane4.setBounds(new Rectangle(97, 49, 579, 100));
       yuan_jLabel19.setText("试卷:");
       yuan_jLabel19.setBounds(new Rectangle(25, 144, 75, 23));
       yuan_jLabel21.setText("答案:");
       yuan_jLabel21.setBounds(new Rectangle(399, 144, 73, 27));
       yuan_jScrollPane5.setBounds(new Rectangle(23, 170, 372, 238));
       yuan_jScrollPane6.setBounds(new Rectangle(404, 170, 306, 238));
       yuan_jButton3.setBounds(new Rectangle(33, 424, 121, 31));
       yuan_jButton3.setText("下载此试卷");
       yuan_jButton3.addActionListener(new MainFace_User_jButton3_actionAdapter(this));
       yuan_jButton4.setBounds(new Rectangle(200, 423, 130, 32));
       yuan_jButton4.setText("上传试卷");
       yuan_jButton4.addActionListener(new MainFace_User_jButton4_actionAdapter(this));

        jTabbedPane1.add(JP_TextMade, "试卷管理");

        JP_TextControl.add(jLabel11);
        JP_TextControl.add(jLabel13);
        JP_TextControl.add(jLabel14);
        JP_TextControl.add(jLabel17);
        JP_TextControl.add(jScrollPane2);
        JP_TextControl.add(jScrollPane3);
        JP_TextControl.add(jLabel18);
        JP_TextControl.add(B_AddText);
        JP_TextControl.add(B_DeteleText);
        JP_TextControl.add(Text_Course);
        JP_TextControl.add(Text_Type1);
        JP_TextControl.add(Chapter);
        JP_TextControl.add(jLabel19);
        JP_TextControl.add(js);
        JP_TextControl.add(Section);
        JP_TextControl.add(jLabel15);
        JP_TextControl.add(Text_Type2);
        JP_TextControl.add(jLabel16);
        JP_TextControl.add(Text_Difficulty);
        js.getViewport().add(TextTable);
        jScrollPane3.getViewport().add(Text_Key);

        jScrollPane2.getViewport().add(Text_Subject);
        JP_getUserID1.setText(id);
        JP_getUserName.setText(name);
        JP_getProfessor.setText(profass);
        JP_getLevel.setText(level);
      //  JP_getCourse.setText(course);
        JP_getDepartment.setText(department);

4 楼


        jTabbedPane1.add(JP_TextControl, "习题管理");
        jTabbedPane1.add(JP_TextMade, "试卷生成");
        jTabbedPane1.add(JP_UserInfo, "用户管理");
        JP_UserInfo.add(jSplitPane1);
        jPanel2.add(JP_getPassword1);
        jPanel2.add(jLabel7);
        jPanel2.add(jLabel12);
        jPanel2.add(JP_getPassword2);
        jPanel2.add(jLabel2);
        jPanel2.add(B_ChangeUserPa);
        jPanel2.add(B_CancelPa);

        this.getContentPane().add(jLabel20);
        this.getContentPane().add(jTabbedPane1);

        jPanel1.add(JP_getUserName);
        jPanel1.add(jLabel3);
        jPanel1.add(jLabel4);
        jPanel1.add(jLabel8);
        jPanel1.add(jLabel9);
        jPanel1.add(jLabel6);
        jPanel1.add(jLabel5);
        jPanel1.add(JP_getDepartment);
        jPanel1.add(JP_getCourse);
        jPanel1.add(JP_getLevel);
        jPanel1.add(JP_getProfessor);
        jPanel1.add(JP_getUserID1);
        jPanel1.add(B_ChangeUserInfo);
        jPanel1.add(B_CancelUserInfo);
        jPanel1.add(jButton1);
        jPanel1.add(jLabel1);
        jSplitPane1.add(jPanel2, JSplitPane.BOTTOM);
        jSplitPane1.add(jPanel1, JSplitPane.TOP);
        jSplitPane1.setDividerLocation(300);
        JP_TextMade.add(yuan_jLabel10);
       JP_TextMade.add(yuan_jComboBox1);
       JP_TextMade.add(yuan_jLabel19);
       JP_TextMade.add(yuan_jLabel21);
       JP_TextMade.add(yuan_jScrollPane5);
       yuan_jScrollPane5.getViewport().add(yuan_jTextArea1);
       JP_TextMade.add(yuan_jScrollPane6);
       yuan_jScrollPane6.getViewport().add(yuan_jTextArea2);
       JP_TextMade.add(yuan_jTextField1);
       JP_TextMade.add(yuan_jButton2);
       JP_TextMade.add(yuan_jButton3);
       JP_TextMade.add(yuan_jButton4);
       JP_TextMade.add(yuam_autonewtest);
       JP_TextMade.add(yuan_newtest);
       JP_TextMade.add(yuan_jScrollPane4);
       yuan_jScrollPane4.getViewport().add(yuan_testTable);
       yuan_testTable.getSelectionModel().addListSelectionListener(this);
       settestcol();//////////////////////////////////
       yuan_jComboBox1.setSelectedIndex(0);


        this.setVisible(true);
    }

5 楼

Vector  SQLbean = new Vector();                          //mincong
    JTabbedPane jTabbedPane1 = new JTabbedPane();
    JPanel JP_TextControl = new JPanel();
    JPanel JP_TextMade = new JPanel();
    JPanel JP_UserInfo = new JPanel();
    JSplitPane jSplitPane1 = new JSplitPane();
    JPanel jPanel1 = new JPanel();
    JPanel jPanel2 = new JPanel();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JLabel jLabel7 = new JLabel();
    JLabel jLabel8 = new JLabel();
    JLabel jLabel9 = new JLabel();
    JLabel JP_getUserID1 = new JLabel();
    JTextField JP_getUserName = new JTextField();
    JTextField JP_getDepartment = new JTextField();
    JTextField JP_getProfessor = new JTextField();
    JTextField JP_getLevel = new JTextField();
    JButton B_ChangeUserInfo = new JButton();
    JButton B_CancelUserInfo = new JButton();
    JLabel jLabel12 = new JLabel();
    JPasswordField JP_getPassword1 = new JPasswordField();
    JPasswordField JP_getPassword2 = new JPasswordField();
    JButton B_ChangeUserPa = new JButton();
    JButton B_CancelPa = new JButton();
    JLabel jLabel11 = new JLabel();
    JComboBox Text_Type1 = new JComboBox();
    JLabel jLabel13 = new JLabel();
    JComboBox Text_Course = new JComboBox();
    JLabel jLabel14 = new JLabel();
    JTextField Chapter = new JTextField();
    JLabel jLabel15 = new JLabel();
    JComboBox Text_Type2 = new JComboBox();
    JLabel jLabel16 = new JLabel();
    JComboBox Text_Difficulty = new JComboBox();
    JLabel jLabel17 = new JLabel();
    JScrollPane jScrollPane2 = new JScrollPane();
    JTextArea Text_Subject = new JTextArea();
    JLabel jLabel18 = new JLabel();
    JScrollPane jScrollPane3 = new JScrollPane();
    JTextArea Text_Key = new JTextArea();
    JButton B_DeteleText = new JButton();
    JButton B_AddText = new JButton();
    JTextField Section = new JTextField();
    JLabel jLabel19 = new JLabel();
    UserBean user=ClientSocket.getUserBean();
    JLabel jLabel20 = new JLabel(new ImageIcon("image/image1.png"));
    Vector usercourse=new Vector();
    Vector SqlBean=new Vector();
    JButton jButton1 = new JButton();
    JTextField JP_getCourse = new JTextField();
    UserBean data=ClientSocket.getUserBean();
    String id = data.getUser_id();
    String name = data.getUser_name();
    String profass = data.getProfessor();
    String level = data.getLevel();
    String department = data.getDepartment_name();

    int count;
    String getUserCid="";//用于储当前操作用户的所教的课程ID
    Vector StoreText=new Vector();
    //用于处理JTable
    DefaultTableModel model=new DefaultTableModel();
    JTable TextTable = new JTable(model);///////////////////////////////////////////////
    JScrollPane js=new JScrollPane(TextTable);/////////////////////////////////////////
    Vector columnNamanes=new Vector();
    String preId="";//保存JTable点击事件的第一个参数
    String textoj="";
    Vector data1=new Vector();

6 楼

/////////////////////////////////////////////////////////////////////////////////////////////////
    String [] testquery={"","按课程名","按创建者","按试题类型","按创建日期"};///////////////////////////////
    JButton yuan_newtest = new JButton();
    JButton yuam_autonewtest = new JButton();
    JLabel yuan_jLabel10 = new JLabel();
    JComboBox yuan_jComboBox1 = new JComboBox(testquery);
    JTextField yuan_jTextField1 = new JTextField();
    JButton yuan_jButton2 = new JButton();
    JScrollPane yuan_jScrollPane4 = new JScrollPane();
    JLabel yuan_jLabel19 = new JLabel();
    JLabel yuan_jLabel21 = new JLabel();
    JScrollPane yuan_jScrollPane5 = new JScrollPane();
    JScrollPane yuan_jScrollPane6 = new JScrollPane();
    JButton yuan_jButton3 = new JButton();
    JButton yuan_jButton4 = new JButton();
    JTextArea yuan_jTextArea1 = new JTextArea();
    JTextArea yuan_jTextArea2 = new JTextArea();
    DefaultTableModel testmodel=new DefaultTableModel();
    JTable yuan_testTable = new JTable(testmodel);
    int selectTestID=-1;
    Vector tests=new Vector();
     Vector datatests=new Vector();
     Vector testscol=new Vector();
     public void settestcol(){
        testscol.addElement("ID");
         testscol.addElement("course_name");
          testscol.addElement("user_name");
          testscol.addElement("test_type");
           testscol.addElement("date");
    }
    public void loadttestdata(){
        Vector s1;
        datatests.clear();
        selectTestID=-1;
        for(int i=0;i<tests.size();i++){
            s1=(Vector)tests.elementAt(i);
            Vector sts=new Vector();
            sts.addElement(i+1);
            for(int j=0;j<4;j++){
                sts.addElement(s1.elementAt(j));
            }
            datatests.addElement(sts);
        }
        if(datatests.size()>0) testmodel.setDataVector(datatests,testscol);
    }
     public void valueChanged(ListSelectionEvent e){
        selectTestID= yuan_testTable.getSelectedRow();
        if(selectTestID<0)return;
        yuan_jTextArea1.setText(((Vector)tests.elementAt(selectTestID)).elementAt(4).toString());
        yuan_jTextArea2.setText(((Vector)tests.elementAt(selectTestID)).elementAt(5).toString());
     }

    public void newtest_actionPerformed(ActionEvent e) {
        Borntest bt=new Borntest();
        bt.validate();
    }

    public void load_actionPerformed(ActionEvent e) {
        PrintWriter outfile;
        if(selectTestID<0) return;
        JFileChooser chooser=new JFileChooser();
        chooser.showSaveDialog(null);
        File file=chooser.getSelectedFile();
        if(file==null){
             return;
        }else{
            try {
                 outfile = new PrintWriter(new FileWriter(file));
                 outfile.print(yuan_jTextArea1.getText());
                 outfile.close();
                 outfile=null;
                 String name=file.getAbsolutePath();
                 name=name.substring(0,name.length()-4)+"Answer.doc";
                 outfile = new PrintWriter(new FileWriter(name));
                 outfile.print(yuan_jTextArea2.getText());
                 outfile.close();
                 outfile=null;
            } catch (IOException ex) {
                System.err.println(ex.toString());
            }
        }
    }

7 楼

public void tranfers_actionPerformed(ActionEvent e) {
       Loadup loadup=new Loadup(this,"试卷上传",true);
    }

    public void autonewtest_actionPerformed(ActionEvent e) {

    ///////////////////////////////////////////////////////////////////
    }

    public void quary_actionPerformed(ActionEvent e) {
      int i= yuan_jComboBox1.getSelectedIndex();
      System.out.println(i+" jComboBox1");//////////
      String se= yuan_jTextField1.getText();
      if(i==0||se.equals(""))return;
      String sql="select * from test where "+testscol.elementAt(i)+"='"+se+"';";
      ClientSocket.loadtest(sql,tests);
      loadttestdata();
    }


////////////////////////////////////////////////
    public void setcol(){//////////////////////////////////////
        columnNamanes.clear();
        columnNamanes.addElement("题目ID");
        columnNamanes.addElement("章");
        columnNamanes.addElement("节");
        columnNamanes.addElement("难度");
       }//////////////////////////////////////////////////////////

       public void Text_Type1_actionPerformed(ActionEvent e) {
            Text_Subject.setText("");
            Text_Key.setText("");
            data1.clear();
            preId="";
            if(Text_Course.getSelectedIndex()<1||Text_Type1.getSelectedIndex()<1){
               model.setDataVector(data1,columnNamanes);
               return;
           }
            boolean nu=false;
            Vector ea;
            int j=0;
            for(int i=0;i<StoreText.size();i++){
                ea=(Vector)StoreText.elementAt(i);
                Vector da=new Vector();
                if(ea.elementAt(1).equals(Text_Course.getSelectedItem())&&ea.elementAt(2).equals(Text_Type1.getSelectedItem())){
                    for (j = 0; j < 8; j++)
                        if (j < 1 || j > 4)
                            da.addElement(ea.elementAt(j));
                    nu=true;
                }
                if(nu==true)
                    data1.addElement(da);
                nu=false;
            }

            model.setDataVector(data1,columnNamanes);
        }


       public void Text_Course_actionPerformed(ActionEvent e) {
           data1.clear();
           preId="";
           Text_Subject.setText("");
           Text_Key.setText("");
           if(Text_Course.getSelectedIndex()<1||Text_Type1.getSelectedIndex()<1){
               model.setDataVector(data1,columnNamanes);
               return;
           }
           //把习题的内容放到JTable里面
            boolean nu=false;
            Vector ea;
            int j=0;
            for(int i=0;i<StoreText.size();i++){
                ea=(Vector)StoreText.elementAt(i);
                Vector da=new Vector();
                if(ea.elementAt(1).equals(Text_Course.getSelectedItem())&&ea.elementAt(2).equals(Text_Type1.getSelectedItem())){
                    for (j = 0; j < 8; j++)
                        if (j < 1 || j > 4)
                            da.addElement(ea.elementAt(j));
                    nu=true;
                }
                if(nu==true)
                    data1.addElement(da);
                nu=false;
            }

            model.setDataVector(data1,columnNamanes);
    }

8 楼

public void B_AddText_actionPerformed(ActionEvent e) {
        //判断当前的用户是否是添加试题所在课程的任课老师
         boolean jubgement=false;
         for(int i=0;i<usercourse.size()&&jubgement==false;i++)
            if(Text_Course.getSelectedItem().equals(usercourse.elementAt(i).toString())){
                 jubgement = true;
                 break;
           }
         if(jubgement==false){
                 JOptionPane.showMessageDialog(null, "你不是此题目的任课老师,不能作添加操作!", "操作提示",
                                           JOptionPane.WARNING_MESSAGE);
             return;
         }

        if(Chapter.getText().equals("")){
            JOptionPane.showMessageDialog(null, "题目章为空,请重新填写题目章", "操作提示",
                                          JOptionPane.WARNING_MESSAGE);
            return;
        }
        if(Section.getText().equals("")){
            JOptionPane.showMessageDialog(null, "题目节为空,请重新填写题目节", "操作提示",
                                          JOptionPane.WARNING_MESSAGE);
            return;
        }
        if(Text_Type2.getSelectedIndex()<1){
            JOptionPane.showMessageDialog(null, "题目类型为空,请重新选择题目类型", "操作提示",
                                          JOptionPane.WARNING_MESSAGE);
            return;
        }
        if(Text_Difficulty.getSelectedIndex()<1){
            JOptionPane.showMessageDialog(null, "难度为空,请重新选择难度", "操作提示",
                                          JOptionPane.WARNING_MESSAGE);
            return;
        }

        if(Text_Subject.getText().equals("")){
            JOptionPane.showMessageDialog(null, "题目为空,请重新填写题目", "操作提示",
                                          JOptionPane.WARNING_MESSAGE);
            return;
        }
        if(Text_Key.getText().equals("")){
            JOptionPane.showMessageDialog(null, "题目答案为空,请重新填写题目答案", "操作提示",
                                          JOptionPane.WARNING_MESSAGE);
            return;
        }
        String answer=Text_Key.getText();  //保存题目答案
        String subject=Text_Subject.getText();//保存题目

        String sql="insert into exercises(course_name,type,text,answer,chapter,section,difficulty) values('"+Text_Course.getSelectedItem()+"','"+Text_Type2.getSelectedItem()+"','"+subject+"','"+answer+"','"+Chapter.getText()+"','"+Section.getText()+"','"+Text_Difficulty.getSelectedItem()+"');";
        SqlBean.addElement(sql);
        ClientSocket.write(SqlBean);SqlBean.clear();

        StoreText.clear();
        String sqlStr = "select * from exercises";
        ClientSocket.read(sqlStr, StoreText);
        if(Text_Type1.getSelectedItem().equals(Text_Type2.getSelectedItem())){
        data1.clear();
        boolean nu=false;
        Vector ea;
        int j=0;
        for(int i=0;i<StoreText.size();i++){
            ea=(Vector)StoreText.elementAt(i);
            Vector da=new Vector();
            if(ea.elementAt(1).equals(Text_Course.getSelectedItem())&&ea.elementAt(2).equals(Text_Type1.getSelectedItem())){
                for (j = 0; j < 8; j++)
                    if (j < 1 || j > 4)
                        da.addElement(ea.elementAt(j));
                nu=true;
            }
            if(nu==true)
                data1.addElement(da);
            nu=false;
        }

        model.setDataVector(data1,columnNamanes);
        }
    }

9 楼

public void B_DeteleText_actionPerformed(ActionEvent e) {

         boolean jubgement1=false;
         if(preId.equals("")){
             JOptionPane.showMessageDialog(null, "当前没有选中题目", "操作提示",
                                           JOptionPane.WARNING_MESSAGE);
             return;
         }
         for(int i=0;i<usercourse.size()&&jubgement1==false;i++)
             if(Text_Course.getSelectedItem().equals(usercourse.elementAt(i).toString())){
                  jubgement1 = true;
                  break;
            }

         if(jubgement1==false){
                 JOptionPane.showMessageDialog(null, "你不是此题目的任课老师,不能作删除操作!", "操作提示",
                                           JOptionPane.WARNING_MESSAGE);
             return;
         }
         Text_Subject.setText("");
         Text_Key.setText("");
         model.fireTableStructureChanged();
         //作删除操作
         String sql="delete from exercises where id="+Integer.parseInt(preId)+";" ;
         SqlBean.addElement(sql);
         ClientSocket.write(SqlBean);SqlBean.clear();

         StoreText.clear();
         String sqlStr = "select * from exercises";
         ClientSocket.read(sqlStr, StoreText);
         data1.clear();
         boolean nu=false;
         Vector ea;
         int j=0;
         for(int i=0;i<StoreText.size();i++){
             ea=(Vector)StoreText.elementAt(i);
             Vector da=new Vector();
             if(ea.elementAt(1).equals(Text_Course.getSelectedItem())&&ea.elementAt(2).equals(Text_Type1.getSelectedItem())){
                 for (j = 0; j < 8; j++)
                     if (j < 1 || j > 4)
                         da.addElement(ea.elementAt(j));
                 nu=true;
             }
             if(nu==true)
                 data1.addElement(da);
             nu=false;
         }
         model.setDataVector(data1,columnNamanes);

     }

    public void B_ChangeUserInfo_actionPerformed(ActionEvent e) {          //mincong
        UserBean data=ClientSocket.getUserBean();
        String id = data.getUser_id();
        String name = JP_getUserName.getText();
        String profass = JP_getProfessor.getText();
        String level = JP_getLevel.getText();
        String course = JP_getCourse.getText();
        String department = JP_getDepartment.getText();
        String sql1 = "update user set user_name='"+name+"' ,level='"+level+"',professor='"+profass+"',department_name='"+department+"' where user_id='"+id+"';";
        String sql2 = "update user_course set course_name='"+course+"' where user_id='"+id+"';";
        SQLbean.addElement(sql1);
        SQLbean.addElement(sql2);
        ClientSocket.write(SQLbean);
        SQLbean.clear();

    }

    public void B_CancelUserInfo_actionPerformed(ActionEvent e) {         //mincong
        JP_getUserName.setText("");
        JP_getLevel.setText("");
        JP_getProfessor.setText("");
        JP_getCourse.setText("");
        JP_getDepartment.setText("");
    }

10 楼

public void jButton1_actionPerformed(ActionEvent e) {         //mincong
        UserBean data=ClientSocket.getUserBean();
        String pow=data.getIsAdmin();
        if(pow.equals("true"))
        {
            MainFace_Admin f = new MainFace_Admin();
            f.setSize(600,500);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        }
        else
            JOptionPane.showMessageDialog(null, "没有该权限!");
    }

    public void B_ChangeUserPa_actionPerformed(ActionEvent e) {         //mincong
        UserBean data=ClientSocket.getUserBean();
        String id = data.getUser_id();
        char ch1 [] = JP_getPassword1.getPassword();
        char ch2 [] = JP_getPassword2.getPassword();
        String a =new String(ch1);
        String b =new String(ch2);
        String sql = "update user set password='"+a+"' where user_id='"+id+"';";
        if(a.equals(b))
        {
            SQLbean.addElement(sql);//
            ClientSocket.write(SQLbean);//密码发到数据库
            SQLbean.clear();
            JOptionPane.showMessageDialog(null, "修改成功!");
        }
        else
            JOptionPane.showMessageDialog(null, "密码不一致,请重新输入!");
    }

    public void B_CancelPa_actionPerformed(ActionEvent e) {            //mincong
        JP_getPassword1.setText("");
        JP_getPassword2.setText("");
    }

    public void this_windowClosing(WindowEvent e) {           //mincong
        ClientSocket.close();
    }

    public void Text_Difficulty_actionPerformed(ActionEvent e) {

    }
}


class MainFace_User_Text_Difficulty_actionAdapter implements ActionListener {
    private MainFace_User adaptee;
    MainFace_User_Text_Difficulty_actionAdapter(MainFace_User adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.Text_Difficulty_actionPerformed(e);
    }
}


class MainFace_User_this_windowAdapter extends WindowAdapter {
    private MainFace_User adaptee;
    MainFace_User_this_windowAdapter(MainFace_User adaptee) {
        this.adaptee = adaptee;
    }

    public void windowClosing(WindowEvent e) {
        adaptee.this_windowClosing(e);
    }
}


class MainFace_User_B_CancelPa_actionAdapter implements ActionListener {     //mincong
    private MainFace_User adaptee;
    MainFace_User_B_CancelPa_actionAdapter(MainFace_User adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.B_CancelPa_actionPerformed(e);
    }
}

我来回复

您尚未登录,请登录后再回复。点此登录或注册