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

📄 optionframe.java

📁 支持GUI和持久对象的联机测试系统
💻 JAVA
字号:
package olts.display;

import olts.OnLineTestSystem;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.*;
import javax.swing.UIManager;
import java.awt.GridLayout;
import javax.swing.JRadioButton;
import javax.swing.JLabel;
import javax.swing.JScrollBar;
import javax.swing.JSlider;
import javax.swing.JList;
import javax.swing.JComboBox;
import javax.swing.JButton;
import java.awt.FlowLayout;

public class OptionFrame extends JDialog {

	private JPanel jContentPane = null;
	private JPanel jPanel = null;
	private JPanel jPanel1 = null;
	private JPanel jPanel3 = null;
	private JRadioButton jRadioButton = null;
	private JRadioButton jRadioButton1 = null;
	private JRadioButton jRadioButton2 = null;
	private JPanel jPanel5 = null;
	private JLabel jLabel = null;
	private JComboBox jComboBox = null;
	private JLabel jLabel1 = null;
	private JComboBox jComboBox1 = null;
	private JLabel jLabel2 = null;
	private JButton jButton = null;
	private JLabel jLabel3 = null;
	private OnLineTestSystem system;
	/**
	 * This is the default constructor
	 */
	public OptionFrame(OnLineTestSystem system) {
		super();
		this.system = system;
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		try{
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        }catch(Exception e){
            
        }
		this.setContentPane(getJContentPane());
		this.setTitle("选 项");
		this.setLocation(new java.awt.Point(150,150));
		this.setSize(new java.awt.Dimension(543,333));
        this.setResizable(false);
		ButtonGroup group = new ButtonGroup();
		group.add(jRadioButton);
		group.add(jRadioButton1);
		group.add(jRadioButton2);
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			GridLayout gridLayout = new GridLayout();
			gridLayout.setRows(3);
			gridLayout.setHgap(20);
			gridLayout.setVgap(20);
			gridLayout.setColumns(1);
			jContentPane = new JPanel();
			jContentPane.setLayout(gridLayout);
			jContentPane.add(getJPanel(), null);
			jContentPane.add(getJPanel1(), null);
			jContentPane.add(getJPanel3(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			GridLayout gridLayout1 = new GridLayout();
			gridLayout1.setRows(1);
			gridLayout1.setColumns(4);
			jPanel = new JPanel();
			jPanel.setFont(new java.awt.Font("宋体", java.awt.Font.PLAIN, 15));
			jPanel.setLayout(gridLayout1);
			jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "组题方式", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), new java.awt.Color(51,51,51)));
			jPanel.add(getJRadioButton(), null);
			jPanel.add(getJRadioButton1(), null);
			jPanel.add(getJRadioButton2(), null);
		}
		return jPanel;
	}

	/**
	 * This method initializes jPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			GridLayout gridLayout2 = new GridLayout();
			gridLayout2.setRows(2);
			gridLayout2.setHgap(1);
			gridLayout2.setVgap(0);
			gridLayout2.setColumns(4);
			jPanel1 = new JPanel();
			jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "试题参数", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
			jPanel1.setFont(new java.awt.Font("宋体", java.awt.Font.PLAIN, 15));
			jPanel1.setLayout(gridLayout2);
			jPanel1.add(getJPanel5(), null);
		}
		return jPanel1;
	}

	/**
	 * This method initializes jPanel3	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel3() {
		if (jPanel3 == null) {
			FlowLayout flowLayout = new FlowLayout();
			flowLayout.setVgap(20);
			jPanel3 = new JPanel();
			jPanel3.setLayout(flowLayout);
			jPanel3.add(getJButton(), null);
		}
		return jPanel3;
	}

	/**
	 * This method initializes jRadioButton	
	 * 	
	 * @return javax.swing.JRadioButton	
	 */
	private JRadioButton getJRadioButton() {
		if (jRadioButton == null) {
			jRadioButton = new JRadioButton();
			jRadioButton.setText("按顺序组题");
			jRadioButton.setFont(new java.awt.Font("宋体", java.awt.Font.PLAIN, 12));
			jRadioButton.setSelected(true);
			jRadioButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					system.setMode(0);
				}
			});
		}
		return jRadioButton;
	}

	/**
	 * This method initializes jRadioButton1	
	 * 	
	 * @return javax.swing.JRadioButton	
	 */
	private JRadioButton getJRadioButton1() {
		if (jRadioButton1 == null) {
			jRadioButton1 = new JRadioButton();
			jRadioButton1.setText("按难度组题");
			jRadioButton1.setFont(new java.awt.Font("宋体", java.awt.Font.PLAIN, 12));
			jRadioButton1.setSelected(false);
			jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					system.setMode(1);
				}
			});
		}
		return jRadioButton1;
	}

	/**
	 * This method initializes jRadioButton2	
	 * 	
	 * @return javax.swing.JRadioButton	
	 */
	private JRadioButton getJRadioButton2() {
		if (jRadioButton2 == null) {
			jRadioButton2 = new JRadioButton();
			jRadioButton2.setText("按随机组题");
			jRadioButton2.setFont(new java.awt.Font("宋体", java.awt.Font.PLAIN, 12));
			jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					system.setMode(2);
				}
			});
		}
		return jRadioButton2;
	}

	/**
	 * This method initializes jPanel5	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel5() {
		if (jPanel5 == null) {
			jLabel3 = new JLabel();
			jLabel3.setText("");
			jLabel2 = new JLabel();
			jLabel2.setText("");
			jLabel1 = new JLabel();
			jLabel1.setText("题目难度: ");
			jLabel1.setPreferredSize(new java.awt.Dimension(83,35));
			jLabel1.setFont(new java.awt.Font("宋体", java.awt.Font.PLAIN, 12));
			jLabel = new JLabel();
			jLabel.setText("题目数量:");
			jLabel.setPreferredSize(new java.awt.Dimension(75,35));
			jLabel.setFont(new java.awt.Font("宋体", java.awt.Font.PLAIN, 12));
			GridLayout gridLayout3 = new GridLayout();
			gridLayout3.setRows(1);
			gridLayout3.setColumns(6);
			jPanel5 = new JPanel();
			jPanel5.setLayout(gridLayout3);
			jPanel5.add(jLabel, null);
			jPanel5.add(getJComboBox(), null);
			jPanel5.add(jLabel2, null);
			jPanel5.add(jLabel1, null);
			jPanel5.add(getJComboBox1(), null);
			jPanel5.add(jLabel3, null);
		}
		return jPanel5;
	}

	/**
	 * This method initializes jComboBox	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBox() {
		if (jComboBox == null) {
			String number[] = {"10", "20", "30", "50", "80"};
			jComboBox = new JComboBox(number);
			jComboBox.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					system.setItemNumber(10);
				}
			});
		}
		return jComboBox;
	}

	/**
	 * This method initializes jComboBox1	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBox1() {
		if (jComboBox1 == null) {
			String level[] = {"1", "2", "3", "4", "5"};
			jComboBox1 = new JComboBox(level);
		}
		return jComboBox1;
	}

	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setText("确   定");
			jButton.setPreferredSize(new java.awt.Dimension(75,30));
			jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					int difficulty =  Integer.parseInt((String)(jComboBox1.getSelectedItem()));
					system.setDifficulty(difficulty);
					int count = Integer.parseInt((String)(jComboBox.getSelectedItem()));
					system.setItemNumber(count);
					close();
				}
			});
		}
		return jButton;
	}

	private void close(){
		this.setVisible(false);
	}
	
}  //  @jve:decl-index=0:visual-constraint="10,10"

⌨️ 快捷键说明

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