本文整理汇总了Java中javax.swing.JCheckBox.setActionCommand方法的典型用法代码示例。如果您正苦于以下问题:Java JCheckBox.setActionCommand方法的具体用法?Java JCheckBox.setActionCommand怎么用?Java JCheckBox.setActionCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JCheckBox
的用法示例。
在下文中一共展示了JCheckBox.setActionCommand方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCheckBoxToPanel
import javax.swing.JCheckBox; //导入方法依赖的package包/类
public void addCheckBoxToPanel(Food food) {
JFrame frame = this;
jPanel2.setLayout(new GridLayout(0, 4));
final JCheckBox box = new JCheckBox(food.getFood());
box.setActionCommand(String.valueOf(food.getId()));
box.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (box.isSelected()) {
jTextArea1.append(box.getText() + "\n");
selectedFoodIds.add(Integer.parseInt(box.getActionCommand()));
}
}
});
jPanel2.add(box);
frame.revalidate();
frame.repaint();
}
示例2: createPlotAllCheckbox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private Component createPlotAllCheckbox() {
drawAllIcons = new JCheckBox("Draw All Center Icons",false);
drawAllIcons.addActionListener(this);
drawAllIcons.setActionCommand("drawAll");
drawAllIcons.setEnabled(false);
return drawAllIcons;
}
示例3: createThumbsCheckbox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
protected Component createThumbsCheckbox() {
thumbsB = new JCheckBox("<html>Image Viewer</html>",true);
thumbsB.setSize(45, 45);
thumbsB.addActionListener(this);
thumbsB.setActionCommand("thumb");
thumbsB.setEnabled(false);
return thumbsB;
}
示例4: createPlotCheckbox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
protected Component createPlotCheckbox() {
plotB = new JCheckBox("<html>Plot Refresh</html>",true);
plotB.setSize(50, 45);
plotB.addActionListener(this);
plotB.setActionCommand("plotS");
plotB.setEnabled(false);
return plotB;
}
示例5: createAllPlotableCheckbox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
protected Component createAllPlotableCheckbox() {
plotAllB = new JCheckBox("<html>Plot All</html>",true);
plotAllB.setSize(50, 45);
plotAllB.addActionListener(this);
plotAllB.setActionCommand("plotAll");
plotAllB.setEnabled(false);
return plotAllB;
}
示例6: checkbox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
protected JCheckBox checkbox(String name, boolean selected)
{
JCheckBox rb = new JCheckBox(name);
rb.setActionCommand(name);
rb.setText("");
rb.setSelected(selected);
checks.put(name, rb);
return rb;
}
示例7: SelectionBar
import javax.swing.JCheckBox; //导入方法依赖的package包/类
public SelectionBar()
{
super();
Messenger.register(MT.SERIES_CHANGED, this);
setLayout(new MigLayout("ins 2, center, gap 4"));
setBorder(new BevelBorder(0));
Font f = new Font(Font.DIALOG, Font.BOLD, 14);
eventSelect = new JComboBox<Event>();
eventSelect.setActionCommand("eventChange");
eventSelect.addActionListener(this);
lock = new JCheckBox("Lock");
lock.setActionCommand("lockEvent");
lock.addActionListener(this);
JLabel dl = new JLabel("Series:");
dl.setFont(f);
JLabel el = new JLabel("Event:");
el.setFont(f);
add(dl, "");
add(new CurrentSeriesLabel(), "");
add(el, "gap left 25");
add(eventSelect, "");
add(lock, "");
}
示例8: actionPerformed
import javax.swing.JCheckBox; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
JCheckBox firstEntry = null;
JPopupMenu popupMenu = new JPopupMenu();
JPanel menuPanel = new JPanel();
menuPanel.setFocusCycleRoot(true);
popupMenu.add(menuPanel);
menuPanel.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.anchor = GridBagConstraints.BASELINE_LEADING;
constraints.weightx = 1;
constraints.gridx = 0;
Set<Integer> visibleColumns = dataPanel.getVisibleColumns();
DataViewTableUIModel dvtm = dataPanel.getModel();
for(int i = 0; i < dvtm.getColumnCount(); i++) {
JCheckBox columnEntry = new JCheckBox(dvtm.getColumnName(i));
columnEntry.setActionCommand(Integer.toString(i));
columnEntry.setSelected(visibleColumns.contains(i));
columnEntry.addActionListener(columnVisibilityToggler);
constraints.gridy += 1;
menuPanel.add(columnEntry, constraints);
if(firstEntry == null) {
firstEntry = columnEntry;
}
}
constraints.gridy += 1;
menuPanel.add(new JSeparator(), constraints);
JCheckBox checkboxItem = new JCheckBox("Fit column width");
checkboxItem.setSelected(dataPanel.getAutoResizeMode() != JTable.AUTO_RESIZE_OFF);
checkboxItem.addActionListener(fitColumnWidthToggler);
constraints.gridy += 1;
menuPanel.add(checkboxItem, constraints);
popupMenu.show(button, 0, button.getHeight());
if(firstEntry == null) {
checkboxItem.requestFocus();
} else {
firstEntry.requestFocus();
}
}