⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 additem.java

📁 包括源代码
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package testgui;import DBOperation.DBItem;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JTextField;/** * * @author RJ-408 */public class AddItem extends JDialog implements ActionListener {    JLabel 题型, 难度系数, 设置时间, 分数, 题目内容, 答案;    JTextField 题目内容1, 答案1;    JComboBox 题型1, 难度系数1, 设置时间1, 分数1;        String[] ItemType = {        "",        "选择题",        "判断题",        "填空题"    };    String[] ItemDif = {        "",        "简单",        "中等",        "较难"    };    String[] Time = {        "",        "60000",        "120000",        "180000"    };    String[] Score = {        "",        "1",        "2",        "3"    };    JButton 确定, 重置;    public AddItem(){    }    public AddItem(UserTest usertest) {        //super(usertest,"设置新题",false);        super();        题型     = new JLabel("题        型:");        难度系数 = new JLabel("难度系数:");        设置时间 = new JLabel("设置时间:");        分数 = new JLabel("分        数:");        题目内容 = new JLabel("题目内容:");        答案 = new JLabel("答        案:");        题型1 = new JComboBox(ItemType);        题型1.setEditable(false); //       题型1.addActionListener(this);        难度系数1 = new JComboBox(ItemDif);        难度系数1.setEditable(false);//        难度系数1.addActionListener(this);        设置时间1 = new JComboBox(Time);        设置时间1.setEditable(false);//        设置时间1.addActionListener(this);        分数1 = new JComboBox(Score);        分数1.setEditable(false);//        分数1.addActionListener(this);        题目内容1 = new JTextField(10);        答案1 = new JTextField(10);        题型.setBounds(10, 10, 10, 10);        题型1.setBounds(90, 10, 150, 10);        难度系数.setBounds(10, 20, 10, 10);        难度系数1.setBounds(90, 20, 150, 10);        设置时间.setBounds(10, 30, 10, 10);        设置时间1.setBounds(90, 30, 150, 10);        分数.setBounds(10, 40, 10, 10);        分数1.setBounds(90, 40, 150, 10);        题目内容.setBounds(10, 50, 10, 10);        题目内容1.setBounds(90, 50, 150, 10);        答案.setBounds(10, 60, 10, 10);        答案1.setBounds(90, 60, 150, 10);        确定 = new JButton("确定");        重置 = new JButton("重置");                题目内容1.addActionListener(this);        答案1.addActionListener(this);        确定.addActionListener(this);        重置.addActionListener(this);                setLayout(new FlowLayout(FlowLayout.LEFT,10,10));                add(题型);           add(题型1);        add(难度系数);          add(难度系数1);        add(设置时间);         add(设置时间1);        add(分数);          add(分数1);        add(题目内容);         add(题目内容1);        add(答案);         add(答案1);        add(确定);           add(重置);                this.setBounds(300, 200, 160, 350);        setVisible(false);       // pack();       }    public void actionPerformed(ActionEvent e) {        if (e.getSource() == 重置)         {            题目内容1.setText(null);            答案1.setText(null);            题型1.setSelectedItem(null);            难度系数1.setSelectedItem(null);            设置时间1.setSelectedItem(null);            分数1.setSelectedItem(null);        }        if (e.getSource() == 确定)        {            String s=(String)题型1.getSelectedItem();            int type,dif;            if(s.equals("选择题"))                type=1;            else if(s.equals("判断题"))                type=2;            else                 type=3;            String s1=(String)难度系数1.getSelectedItem();            if(s1.equals("简单"))                dif=1;            else if(s1.equals("中等"))                dif=2;            else                 dif=3;            DBItem item=new DBItem();            item.insertItem(type, dif, 题目内容1.getText(), 答案1.getText(), Integer.parseInt((String)分数1.getSelectedItem()), Integer.parseInt((String)设置时间1.getSelectedItem()));            this.setVisible(false);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -