📄 filterpanel.java
字号:
/*
* FilterPanel.java
*
* Created on 2007年12月18日, 下午4:27
*/
package olts.ui;
import javax.swing.*;
import javax.swing.text.PlainDocument;
import java.awt.event.*;
import javax.swing.event.*;
/**
* 这个类用于实现用户输入抽取试题的条件的面板
* @author Administrator
*/
public class FilterPanel extends javax.swing.JPanel {
/** Creates new form FilterPanel */
public FilterPanel(MainFrame mf) {
initComponents();
this.buttonGroup.add(this.RadioButtonForRandom);
this.buttonGroup.add(this.RadioButtonForCondition);
this.buttonGroup.add(this.RadioButtonForAll);
this.buttonGroup.add(this.RadioButtonForID);
this.mainFrame = mf;
this.RadioButtonForAll.setSelected(true);this.condition = "all";
//设置默认的可面板环境
this.checkBoxByDiff.setEnabled(false);
this.checkBoxByType.setEnabled(false);
this.textFieldForDiff.setEnabled(false);
this.comboBoxForType.setEnabled(false);
this.textFieldForId.setEnabled(false);
this.textFieldForId.setColumns(10);
this.comboBoxForType.removeAllItems();
//设置下拉菜单中的选项
Object[] types = this.mainFrame.getItemTypes();
if (types != null){
for (int i = 0; i < types.length; i++){
this.comboBoxForType.addItem(types[i]);
}
}
//设置文本字段的事件监听
PlainDocument docForDiff = new PlainDocument();
docForDiff.addDocumentListener(new TextChecker());
this.textFieldForDiff.setDocument(docForDiff);
PlainDocument docForID = new PlainDocument();
docForID.addDocumentListener(new TextChecker());
this.textFieldForId.setDocument(docForID);
if (this.mainFrame.isTesting() == true){
this.lableForInfo.setText("欢迎您!请在下面选择试题的产生方式:");
this.RadioButtonForAll.setEnabled(false);
this.RadioButtonForRandom.setSelected(true);
}else {
this.RadioButtonForRandom.setEnabled(false);
this.RadioButtonForAll.setSelected(true);
this.lableForInfo.setText("欢迎您!请在下面选择要进行维护的试题类型");
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup = new javax.swing.ButtonGroup();
infoArea = new javax.swing.JPanel();
lableForInfo = new javax.swing.JLabel();
filterPanel = new javax.swing.JPanel();
RadioButtonForRandom = new javax.swing.JRadioButton();
RadioButtonForAll = new javax.swing.JRadioButton();
RadioButtonForCondition = new javax.swing.JRadioButton();
checkBoxByDiff = new javax.swing.JCheckBox();
checkBoxByType = new javax.swing.JCheckBox();
RadioButtonForID = new javax.swing.JRadioButton();
textFieldForDiff = new javax.swing.JTextField();
comboBoxForType = new javax.swing.JComboBox();
textFieldForId = new javax.swing.JTextField();
sumitPanel = new javax.swing.JPanel();
buttonForEnter = new javax.swing.JButton();
buttonForCancel = new javax.swing.JButton();
javax.swing.GroupLayout infoAreaLayout = new javax.swing.GroupLayout(infoArea);
infoArea.setLayout(infoAreaLayout);
infoAreaLayout.setHorizontalGroup(
infoAreaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(infoAreaLayout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(lableForInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(36, Short.MAX_VALUE))
);
infoAreaLayout.setVerticalGroup(
infoAreaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(infoAreaLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lableForInfo, javax.swing.GroupLayout.DEFAULT_SIZE, 21, Short.MAX_VALUE)
.addContainerGap())
);
filterPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
RadioButtonForRandom.setText("\u968f\u673a\u9009\u62e9");
RadioButtonForRandom.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
RadioButtonForRandom.setMargin(new java.awt.Insets(0, 0, 0, 0));
RadioButtonForRandom.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
RadioButtonForRandomStateChanged(evt);
}
});
RadioButtonForRandom.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
RadioButtonForRandomActionPerformed(evt);
}
});
RadioButtonForAll.setText("\u5168\u90e8\u9009\u62e9");
RadioButtonForAll.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
RadioButtonForAll.setMargin(new java.awt.Insets(0, 0, 0, 0));
RadioButtonForAll.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
RadioButtonForAllStateChanged(evt);
}
});
RadioButtonForAll.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
RadioButtonForAllActionPerformed(evt);
}
});
RadioButtonForCondition.setText("\u7ec4\u5408\u67e5\u8be2\u9009\u62e9");
RadioButtonForCondition.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
RadioButtonForCondition.setMargin(new java.awt.Insets(0, 0, 0, 0));
RadioButtonForCondition.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
RadioButtonForConditionStateChanged(evt);
}
});
checkBoxByDiff.setText("\u8bd5\u9898\u96be\u5ea6");
checkBoxByDiff.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
checkBoxByDiff.setMargin(new java.awt.Insets(0, 0, 0, 0));
checkBoxByDiff.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
checkBoxByDiffStateChanged(evt);
}
});
checkBoxByType.setText("\u8bd5\u9898\u7c7b\u578b");
checkBoxByType.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
checkBoxByType.setMargin(new java.awt.Insets(0, 0, 0, 0));
checkBoxByType.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
checkBoxByTypeStateChanged(evt);
}
});
RadioButtonForID.setText("\u6309ID\u9009\u62e9\u4e00\u9053");
RadioButtonForID.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
RadioButtonForID.setMargin(new java.awt.Insets(0, 0, 0, 0));
RadioButtonForID.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
RadioButtonForIDStateChanged(evt);
}
});
RadioButtonForID.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
RadioButtonForIDActionPerformed(evt);
}
});
comboBoxForType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
javax.swing.GroupLayout filterPanelLayout = new javax.swing.GroupLayout(filterPanel);
filterPanel.setLayout(filterPanelLayout);
filterPanelLayout.setHorizontalGroup(
filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(filterPanelLayout.createSequentialGroup()
.addGroup(filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(filterPanelLayout.createSequentialGroup()
.addGap(59, 59, 59)
.addGroup(filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(checkBoxByDiff)
.addComponent(checkBoxByType)))
.addGroup(filterPanelLayout.createSequentialGroup()
.addGap(32, 32, 32)
.addGroup(filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(RadioButtonForAll)
.addComponent(RadioButtonForRandom)
.addComponent(RadioButtonForCondition)
.addComponent(RadioButtonForID))))
.addGap(27, 27, 27)
.addGroup(filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(textFieldForDiff, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
.addComponent(comboBoxForType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(textFieldForId))
.addContainerGap(198, Short.MAX_VALUE))
);
filterPanelLayout.setVerticalGroup(
filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(filterPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(RadioButtonForRandom)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(RadioButtonForAll)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(RadioButtonForID)
.addComponent(textFieldForId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(RadioButtonForCondition)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(checkBoxByDiff)
.addComponent(textFieldForDiff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(filterPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(checkBoxByType)
.addComponent(comboBoxForType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(31, 31, 31))
);
sumitPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
buttonForEnter.setText("\u786e\u5b9a");
buttonForEnter.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonForEnterActionPerformed(evt);
}
});
buttonForCancel.setText("\u53d6\u6d88");
buttonForCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonForCancelActionPerformed(evt);
}
});
javax.swing.GroupLayout sumitPanelLayout = new javax.swing.GroupLayout(sumitPanel);
sumitPanel.setLayout(sumitPanelLayout);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -