下面列出了javax.swing.JCheckBox#setActionCommand ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
*
* Add a new checkbox to given component
*
* @param container Component to add the checkbox to
* @param text Checkbox' text
* @param icon Checkbox' icon or null
* @param listener Checkbox' listener or null
* @param actionCommand Checkbox' action command or null
* @param mnemonic Checkbox' mnemonic (virtual key code) or 0
* @param toolTip Checkbox' tool tip or null
* @param state Checkbox' state
* @return Created checkbox
*/
public static JCheckBox addCheckbox(Container component, String text, Icon icon,
ActionListener listener, String actionCommand, int mnemonic, String toolTip, boolean state) {
JCheckBox checkbox = new JCheckBox(text, icon, state);
if (listener != null)
checkbox.addActionListener(listener);
if (actionCommand != null)
checkbox.setActionCommand(actionCommand);
if (mnemonic > 0)
checkbox.setMnemonic(mnemonic);
if (toolTip != null)
checkbox.setToolTipText(toolTip);
if (component != null)
component.add(checkbox);
return checkbox;
}
public CheckCritPanel(int crits, int current) {
setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
for (int i = 0; i < crits; i++) {
JCheckBox check = new JCheckBox("");
check.setActionCommand(Integer.toString(i));
check.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
checkBoxes(evt);
}
});
checks.add(check);
add(check);
}
if (current > 0) {
for (int i = 0; i < current; i++) {
checks.get(i).setSelected(true);
}
}
}
/**
*
* Add a new checkbox to given component
*
* @param container Component to add the checkbox to
* @param text Checkbox' text
* @param icon Checkbox' icon or null
* @param listener Checkbox' listener or null
* @param actionCommand Checkbox' action command or null
* @param mnemonic Checkbox' mnemonic (virtual key code) or 0
* @param toolTip Checkbox' tool tip or null
* @param state Checkbox' state
* @return Created checkbox
*/
public static JCheckBox addCheckbox(Container component, String text, Icon icon,
ActionListener listener, String actionCommand, int mnemonic, String toolTip, boolean state) {
JCheckBox checkbox = new JCheckBox(text, icon, state);
if (listener != null)
checkbox.addActionListener(listener);
if (actionCommand != null)
checkbox.setActionCommand(actionCommand);
if (mnemonic > 0)
checkbox.setMnemonic(mnemonic);
if (toolTip != null)
checkbox.setToolTipText(toolTip);
if (component != null)
component.add(checkbox);
return checkbox;
}
@Override
protected JPanel createTickUnitPanel()
{
JPanel tickUnitPanel = new JPanel(new LCBLayout(3));
tickUnitPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
tickUnitPanel.add(new JPanel());
JCheckBox autoTickUnitSelectionCheckBox = new JCheckBox(
localizationResources.getString("Auto-TickUnit_Selection"),
isAutoTickUnitSelection());
autoTickUnitSelectionCheckBox.setActionCommand("AutoTickOnOff");
autoTickUnitSelectionCheckBox.addActionListener(this);
setAutoTickUnitSelectionCheckBox(autoTickUnitSelectionCheckBox);
tickUnitPanel.add(getAutoTickUnitSelectionCheckBox());
tickUnitPanel.add(new JPanel());
tickUnitPanel.add(new JLabel(localizationResources.getString(
"Manual_TickUnit_value")));
this.manualTickUnit = new JTextField(Double.toString(
this.manualTickUnitValue));
this.manualTickUnit.setEnabled(!isAutoTickUnitSelection());
this.manualTickUnit.setActionCommand("TickUnitValue");
this.manualTickUnit.addActionListener(this);
this.manualTickUnit.addFocusListener(this);
tickUnitPanel.add(this.manualTickUnit);
tickUnitPanel.add(new JPanel());
return tickUnitPanel;
}