javax.swing.JComboBox.setActionCommand()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(12.6k)|赞(0)|评价(0)|浏览(181)

本文整理了Java中javax.swing.JComboBox.setActionCommand()方法的一些代码示例,展示了JComboBox.setActionCommand()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComboBox.setActionCommand()方法的具体详情如下:
包路径:javax.swing.JComboBox
类名称:JComboBox
方法名:setActionCommand

JComboBox.setActionCommand介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

JComboBox date1 = new JComboBox (date);
date1.setActionCommand("date1");
date1.addActionListener(this)

代码示例来源:origin: MegaMek/mekhq

@Override
public void actionPerformed(ActionEvent e) {
  TableCellListener tcl = (TableCellListener)e.getSource();
  if (!(tcl.getOldValue().equals(tcl.getNewValue()))) {
    comboRanks.setActionCommand("noFillRanks");
    comboRanks.setSelectedIndex(Ranks.RS_CUSTOM);
    comboRanks.setActionCommand("fillRanks");
  }
}

代码示例来源:origin: stackoverflow.com

JComboBox category = new JComboBox();
category.addActionListener(this);
category.setActionCommand("combo");
category.setBounds(125,200,400,50);
add(category);

category.setModel(new DefaultComboBoxModel<>(cats));

代码示例来源:origin: stackoverflow.com

public void createGUI(){

    setSize(1200, 1000);

    topPanel = new JPanel();

    JComboBox searchType = new JComboBox(new Object[]{"1", "2"});
    JComboBox startVertex = new JComboBox(new Object[]{"1", "2"});
    JComboBox goalVertex = new JComboBox(new Object[]{"1", "2"});

    searchType.setSelectedIndex(1);         
    startVertex.setSelectedIndex(1);          
    startVertex.setActionCommand("start");

    goalVertex.setSelectedIndex(1);
    goalVertex.setActionCommand("goal");

    topPanel.add(searchType);
    topPanel.add(startVertex);
    topPanel.add(goalVertex);

    this.setLayout(new BorderLayout());
    this.add(topPanel, BorderLayout.NORTH);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);

}

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

private JPanel createControlPanel() {
  onTop = new JCheckBox("Top Position in Layer");
  onTop.setSelected(true);
  onTop.setActionCommand(ON_TOP_COMMAND);
  onTop.addActionListener(this);
  layerList = new JComboBox(layerStrings);
  layerList.setSelectedIndex(2);    //cyan layer
  layerList.setActionCommand(LAYER_COMMAND);
  layerList.addActionListener(this);
  JPanel controls = new JPanel();
  controls.add(layerList);
  controls.add(onTop);
  controls.setBorder(BorderFactory.createTitledBorder(
               "Choose Duke's Layer and Position"));
  return controls;
}

代码示例来源:origin: jfree/jcommon

/**
 * Constructs a panel containing two JComboBoxes (for the month and year) and a button
 * (to reset the date to TODAY).
 *
 * @return the panel.
 */
private JPanel constructSelectionPanel() {
  final JPanel p = new JPanel();
  this.monthSelector = new JComboBox(SerialDate.getMonths());
  this.monthSelector.addActionListener(this);
  this.monthSelector.setActionCommand("monthSelectionChanged");
  p.add(this.monthSelector);
  this.yearSelector = new JComboBox(getYears(0));
  this.yearSelector.addActionListener(this);
  this.yearSelector.setActionCommand("yearSelectionChanged");
  p.add(this.yearSelector);
  return p;
}

代码示例来源:origin: org.jfree/jcommon

/**
 * Constructs a panel containing two JComboBoxes (for the month and year) and a button
 * (to reset the date to TODAY).
 *
 * @return the panel.
 */
private JPanel constructSelectionPanel() {
  final JPanel p = new JPanel();
  this.monthSelector = new JComboBox(SerialDate.getMonths());
  this.monthSelector.addActionListener(this);
  this.monthSelector.setActionCommand("monthSelectionChanged");
  p.add(this.monthSelector);
  this.yearSelector = new JComboBox(getYears(0));
  this.yearSelector.addActionListener(this);
  this.yearSelector.setActionCommand("yearSelectionChanged");
  p.add(this.yearSelector);
  return p;
}

代码示例来源:origin: org.jfree/com.springsource.org.jfree

/**
 * Constructs a panel containing two JComboBoxes (for the month and year) and a button
 * (to reset the date to TODAY).
 *
 * @return the panel.
 */
private JPanel constructSelectionPanel() {
  final JPanel p = new JPanel();
  this.monthSelector = new JComboBox(SerialDate.getMonths());
  this.monthSelector.addActionListener(this);
  this.monthSelector.setActionCommand("monthSelectionChanged");
  p.add(this.monthSelector);
  this.yearSelector = new JComboBox(getYears(0));
  this.yearSelector.addActionListener(this);
  this.yearSelector.setActionCommand("yearSelectionChanged");
  p.add(this.yearSelector);
  return p;
}

代码示例来源:origin: jfree/jcommon

/**
 * Creates the content for tab 1.
 *
 * @return The content panel.
 */
private JPanel createTab1Content() {
  final JPanel content = new JPanel(new BorderLayout());
  this.combo1 = new JComboBox();
  this.combo1.setActionCommand("combo1.changed");
  populateTextAnchorCombo(this.combo1);
  this.combo1.addActionListener(this);
  final JPanel controls = new JPanel();
  controls.add(this.combo1);
  final JButton fontButton = new JButton("Select Font...");
  fontButton.setActionCommand("fontButton.clicked");
  fontButton.addActionListener(this);
  controls.add(fontButton);
  content.add(controls, BorderLayout.NORTH);
  this.drawStringPanel1 = new DrawStringPanel("0123456789", false);
  content.add(this.drawStringPanel1);
  return content;
}

代码示例来源:origin: Multibit-Legacy/multibit-hd

/**
 * <p>Creates a combo that is populated asynchronously from the currency and exchange provided</p>
 *
 * @param listener The action listener
 *
 * @return A new "currency code" combo box
 */
public static JComboBox<String> newCurrencyCodeComboBox(ActionListener listener) {
 final JComboBox<String> comboBox = newReadOnlyComboBox(new String[]{});
 // Ensure it is accessible
 AccessibilityDecorator.apply(comboBox, MessageKey.SELECT_LOCAL_CURRENCY, MessageKey.SELECT_LOCAL_CURRENCY_TOOLTIP);
 // Add the listener at the end to avoid false events
 comboBox.setActionCommand(ComboBoxes.CURRENCY_COMMAND);
 comboBox.addActionListener(listener);
 return comboBox;
}

代码示例来源:origin: Multibit-Legacy/multibit-hd

/**
 * @param listener     The action listener to alert when the selection is made
 * @param receiveSound True if the "yes" option should be pre-selected
 *
 * @return A new "yes/no" combo box
 */
public static JComboBox<String> newReceiveSoundYesNoComboBox(ActionListener listener, boolean receiveSound) {
 JComboBox<String> comboBox = newYesNoComboBox(listener, receiveSound);
 // Ensure it is accessible
 AccessibilityDecorator.apply(comboBox, MessageKey.RECEIVE_SOUND, MessageKey.RECEIVE_SOUND_TOOLTIP);
 comboBox.setActionCommand(RECEIVE_SOUND_COMMAND);
 return comboBox;
}

代码示例来源:origin: Multibit-Legacy/multibit-hd

/**
 * @param listener The action listener to alert when the selection is made
 * @param showRestoreBeta7Wallets   True if the "yes" option should be pre-selected
 *
 * @return A new "yes/no" combo box
 */
 public static JComboBox<String> newShowRestoreBeta7WalletsYesNoComboBox(ActionListener listener, boolean showRestoreBeta7Wallets) {
  JComboBox<String> comboBox = newYesNoComboBox(listener, showRestoreBeta7Wallets);
  // Ensure it is accessible
  AccessibilityDecorator.apply(comboBox, MessageKey.SELECT_SHOW_RESTORE_BETA7_WALLETS, MessageKey.SELECT_SHOW_RESTORE_BETA7_WALLETSTOOLTIP);
  comboBox.setActionCommand(SHOW_RESTORE_BETA7_WALLETS_COMMAND);
  return comboBox;
 }

代码示例来源:origin: Multibit-Legacy/multibit-hd

/**
 * @param listener    The action listener to alert when the selection is made
 * @param showBalance True if the "yes" option should be pre-selected
 *
 * @return A new "yes/no" combo box
 */
public static JComboBox<String> newShowBalanceYesNoComboBox(ActionListener listener, boolean showBalance) {
 JComboBox<String> comboBox = newYesNoComboBox(listener, showBalance);
 // Ensure it is accessible
 AccessibilityDecorator.apply(comboBox, MessageKey.SHOW_BALANCE, MessageKey.SHOW_BALANCE_TOOLTIP);
 comboBox.setActionCommand(SHOW_BALANCE_COMMAND);
 return comboBox;
}

代码示例来源:origin: Multibit-Legacy/multibit-hd

/**
 * @param listener    The action listener to alert when the selection is made
 * @param showBalance True if the "yes" option should be pre-selected
 *
 * @return A new "yes/no" combo box
 */
public static JComboBox<String> newShowAtomFeedAlertYesNoComboBox(ActionListener listener, boolean showBalance) {
 JComboBox<String> comboBox = newYesNoComboBox(listener, showBalance);
 // Ensure it is accessible
 AccessibilityDecorator.apply(comboBox, MessageKey.SHOW_ATOM_FEED_ALERT, MessageKey.SHOW_ATOM_FEED_ALERT_TOOLTIP);
 comboBox.setActionCommand(SHOW_ATOM_FEED_ALERT_COMMAND);
 return comboBox;
}

代码示例来源:origin: Multibit-Legacy/multibit-hd

/**
 * @param listener   The action listener to alert when the selection is made
 * @param alertSound True if the "yes" option should be pre-selected
 *
 * @return A new "yes/no" combo box
 */
public static JComboBox<String> newAlertSoundYesNoComboBox(ActionListener listener, boolean alertSound) {
 JComboBox<String> comboBox = newYesNoComboBox(listener, alertSound);
 // Ensure it is accessible
 AccessibilityDecorator.apply(comboBox, MessageKey.ALERT_SOUND, MessageKey.ALERT_SOUND_TOOLTIP);
 comboBox.setActionCommand(ALERT_SOUND_COMMAND);
 return comboBox;
}

代码示例来源:origin: Multibit-Legacy/multibit-hd

/**
 * @param listener The action listener to alert when the selection is made
 * @param useTor   True if the "yes" option should be pre-selected
 *
 * @return A new "yes/no" combo box
 */
public static JComboBox<String> newHardwareYesNoComboBox(ActionListener listener, boolean useTor) {
 JComboBox<String> comboBox = newYesNoComboBox(listener, useTor);
 // Ensure it is accessible
 AccessibilityDecorator.apply(comboBox, MessageKey.SELECT_HARDWARE_WALLET, MessageKey.SELECT_HARDWARE_WALLET_TOOLTIP);
 comboBox.setActionCommand(HARDWARE_COMMAND);
 return comboBox;
}
/**

代码示例来源:origin: Multibit-Legacy/multibit-hd

/**
 * @param listener The action listener to alert when the selection is made
 *
 * @return A new "themes" combo box containing all supported languages and variants
 */
public static JComboBox<String> newThemesComboBox(ActionListener listener) {
 // Get the current themes
 // Populate the combo box and declare a suitable renderer
 JComboBox<String> comboBox = newReadOnlyComboBox(ThemeKey.localisedNames());
 // Ensure it is accessible
 AccessibilityDecorator.apply(comboBox, MessageKey.SELECT_THEME, MessageKey.SELECT_THEME_TOOLTIP);
 // Can use the ordinal due to the declaration ordering
 comboBox.setSelectedIndex(ThemeKey.fromTheme(Themes.currentTheme).ordinal());
 // Add the listener at the end to avoid false events
 comboBox.setActionCommand(THEMES_COMMAND);
 comboBox.addActionListener(listener);
 return comboBox;
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_http

private JPanel createTargetPanel() {
  targetNodesModel = new DefaultComboBoxModel<>();
  targetNodes = new JComboBox<>(targetNodesModel);
  targetNodes.setPrototypeDisplayValue(""); // $NON-NLS-1$ // Bug 56303 fixed the width of combo list
  JPopupMenu popup = (JPopupMenu) targetNodes.getUI().getAccessibleChild(targetNodes, 0); // get popup element
  JScrollPane scrollPane = findScrollPane(popup);
  if(scrollPane != null) {
    scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL)); // add scroll pane if label element is too long
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  }
  targetNodes.setActionCommand(CHANGE_TARGET);
  // Action listener will be added later
  JLabel label = new JLabel(JMeterUtils.getResString("proxy_target")); // $NON-NLS-1$
  label.setLabelFor(targetNodes);
  HorizontalPanel panel = new HorizontalPanel();
  panel.add(label);
  panel.add(targetNodes);
  return panel;
}

代码示例来源:origin: Multibit-Legacy/multibit-hd

/**
 * @param listener             The action listener to alert when the selection is made
 * @param bitcoinConfiguration The Bitcoin configuration to use
 *
 * @return A new "decimal" combo box
 */
public static JComboBox<String> newDecimalComboBox(ActionListener listener, BitcoinConfiguration bitcoinConfiguration) {
 String[] decimalSeparators = Languages.getCurrencySeparators(false);
 JComboBox<String> comboBox = newReadOnlyComboBox(decimalSeparators);
 // Ensure it is accessible
 AccessibilityDecorator.apply(comboBox, MessageKey.SELECT_DECIMAL_SEPARATOR, MessageKey.SELECT_DECIMAL_SEPARATOR_TOOLTIP);
 // Determine the first matching separator
 String decimal = bitcoinConfiguration.getDecimalSeparator();
 selectFirstMatch(comboBox, decimalSeparators, decimal);
 // Add the listener at the end to avoid false events
 comboBox.setActionCommand(DECIMAL_COMMAND);
 comboBox.addActionListener(listener);
 return comboBox;
}

代码示例来源:origin: Multibit-Legacy/multibit-hd

/**
 * @param listener             The action listener to alert when the selection is made
 * @param bitcoinConfiguration The Bitcoin configuration to use
 *
 * @return A new "decimal" combo box
 */
public static JComboBox<String> newGroupingComboBox(ActionListener listener, BitcoinConfiguration bitcoinConfiguration) {
 String[] groupingSeparators = Languages.getCurrencySeparators(true);
 JComboBox<String> comboBox = newReadOnlyComboBox(groupingSeparators);
 // Ensure it is accessible
 AccessibilityDecorator.apply(comboBox, MessageKey.SELECT_GROUPING_SEPARATOR, MessageKey.SELECT_GROUPING_SEPARATOR_TOOLTIP);
 // Determine the first matching separator
 String grouping = bitcoinConfiguration.getGroupingSeparator();
 selectFirstMatch(comboBox, groupingSeparators, grouping);
 // Add the listener at the end to avoid false events
 comboBox.setActionCommand(GROUPING_COMMAND);
 comboBox.addActionListener(listener);
 return comboBox;
}

相关文章

JComboBox类方法