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

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

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

JComboBox.setAction介绍

暂无

代码示例

代码示例来源:origin: chewiebug/GCViewer

private GCViewerGuiToolBar initToolBar(Map<String, Action> actions) {
  GCViewerGuiToolBar toolBar = new GCViewerGuiToolBar();
  toolBar.setFloatable(false);
  
  toolBar.add(actions.get(ActionCommands.OPEN_FILE.toString()));
  toolBar.add(actions.get(ActionCommands.OPEN_SERIES.toString()));
  toolBar.add(actions.get(ActionCommands.OPEN_URL.toString()));
  toolBar.add(actions.get(ActionCommands.EXPORT.toString()));
  toolBar.add(actions.get(ActionCommands.REFRESH.toString()));
  
  JToggleButton watchToggle = new JToggleButton();
  watchToggle.setAction(actions.get(ActionCommands.WATCH.toString()));
  watchToggle.setText("");
  toolBar.addWatchToggleButton(watchToggle);
  
  toolBar.addSeparator();
  
  JComboBox<String> zoomComboBox = new JComboBox<String>(new String[] {"1%", "5%", "10%", "50%", "100%", "200%", "300%", "500%", "1000%", "5000%"});
  zoomComboBox.setSelectedIndex(2);
  zoomComboBox.setAction(actions.get(ActionCommands.ZOOM.toString()));
  zoomComboBox.setEditable(true);
  zoomComboBox.setMaximumSize(zoomComboBox.getPreferredSize());
  toolBar.addZoomComboBox(zoomComboBox);
  
  toolBar.addSeparator();
  
  toolBar.add(actions.get(ActionCommands.ABOUT.toString()));
  
  return toolBar;
}

代码示例来源:origin: sarahtattersall/PIPE

/**
 * Creates and adds the token view combo box to the view
 *
 * @param toolBar the JToolBar to add the combo box to
 * @param action  the action that the tokenClassComboBox performs when selected
 */
protected void addTokenClassComboBox(JToolBar toolBar, Action action) {
  String[] tokenClassChoices = new String[]{"Default"};
  DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>(tokenClassChoices);
  tokenClassComboBox = new JComboBox<>(model);
  tokenClassComboBox.setEditable(true);
  tokenClassComboBox.setSelectedItem(tokenClassChoices[0]);
  tokenClassComboBox.setMaximumRowCount(100);
  //        tokenClassComboBox.setMaximumSize(new Dimension(125, 100));
  tokenClassComboBox.setEditable(false);
  tokenClassComboBox.setAction(action);
  toolBar.add(tokenClassComboBox);
}

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

final JTabbedPane tabbedPane = new JTabbedPane();
final JComboBox items = new JComboBox(new Object[] {
    new MyMenu("one"), new MyMenu("other"), new MyMenu("got it?")
});
Action action = new AbstractAction("showInTab") {

  @Override
  public void actionPerformed(ActionEvent e) {
    MyMenu selected = (MyMenu) items.getSelectedItem();
    int index = tabbedPane.indexOfComponent(selected.getMenuPanel());
    if (index < 0) {
      tabbedPane.addTab(selected.getName(), selected.getMenuPanel());
    } else {
      tabbedPane.setSelectedIndex(index);
    }
  }
};
items.setSelectedIndex(-1);
items.setAction(action);

代码示例来源:origin: sarahtattersall/PIPE

/**
 * Creates and adds the token view combo box to the view
 *
 * @param toolBar the JToolBar to add the combo box to
 * @param action  the action that the tokenClassComboBox performs when selected
 * @param view  application view 
 */
private void addTokenClassComboBox(JToolBar toolBar, Action action, PipeApplicationView view) {
  String[] tokenClassChoices = new String[]{"Default"};
  DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>(tokenClassChoices);
  JComboBox<String> tokenClassComboBox = new JComboBox<>(model);
  tokenClassComboBox.setEditable(true);
  tokenClassComboBox.setSelectedItem(tokenClassChoices[0]);
  tokenClassComboBox.setMaximumRowCount(100);
  tokenClassComboBox.setEditable(false);
  tokenClassComboBox.setAction(action);
  view.register(tokenClassComboBox);
  toolBar.add(tokenClassComboBox);
}

代码示例来源:origin: com.mgmtp.gcviewer/gcviewer

private JToolBar initToolBar() {
  final JToolBar toolBar = new JToolBar();
  toolBar.setFloatable(false);
  toolBar.add(openFileAction);
  toolBar.add(openURLAction);
  toolBar.add(exportAction);
  toolBar.add(refreshAction);
  watchToggle = new JToggleButton();
  watchToggle.setAction(watchAction);
  watchToggle.setText("");
  toolBar.add(watchToggle);
  toolBar.addSeparator();
  zoomComboBox = new JComboBox(new String[] {"1%", "5%", "10%", "50%", "100%", "200%", "300%", "500%", "1000%", "5000%"});
  zoomComboBox.setSelectedIndex(2);
  zoomComboBox.setAction(zoomAction);
  zoomComboBox.setEditable(true);
  zoomComboBox.setMaximumSize(zoomComboBox.getPreferredSize());
  toolBar.add(zoomComboBox);
  toolBar.addSeparator();
  toolBar.add(aboutAction);
  return toolBar;
}

代码示例来源:origin: sarahtattersall/PIPE

/**
 * Adds a zoom combo box to the toolbar
 *
 * @param toolBar the JToolBar to add the button to
 * @param action  the action that the ZoomComboBox performs
 * @param view application view 
 */
private void addZoomComboBox(JToolBar toolBar, Action action, String[] zoomExamples, PipeApplicationView view) {
  Dimension zoomComboBoxDimension = new Dimension(65, 28);
  JComboBox<String> zoomComboBox = new JComboBox<>(zoomExamples);
  zoomComboBox.setEditable(true);
  zoomComboBox.setSelectedItem("100%");
  zoomComboBox.setMaximumRowCount(zoomExamples.length);
  zoomComboBox.setMaximumSize(zoomComboBoxDimension);
  zoomComboBox.setMinimumSize(zoomComboBoxDimension);
  zoomComboBox.setPreferredSize(zoomComboBoxDimension);
  zoomComboBox.setAction(action);
  view.registerZoom(zoomComboBox);
  toolBar.add(zoomComboBox);
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

/**
 * bind the components to the patternModel/actions.
 */
@Override
protected void bind() {
  super.bind();
  List matchRules = getPatternModel().getMatchRules();
  // PENDING: map rules to localized strings
  ComboBoxModel model = new DefaultComboBoxModel(matchRules.toArray());
  model.setSelectedItem(getPatternModel().getMatchRule());
  searchCriteria.setModel(model);
  searchCriteria.setAction(getAction(MATCH_RULE_ACTION_COMMAND));
  
}

代码示例来源:origin: org.xworker/xworker_core

public static void createAction(ActionContext actionContext){
  Thing self = (Thing) actionContext.get("self");
  JComboBox parent = (JComboBox) actionContext.get("parent");
  
  for(Thing child : self.getChilds()){
    Action action = (Action) child.doAction("create", actionContext);
    if(action != null){
      parent.setAction(action);
      break;
    }
  }
}

代码示例来源:origin: com.atlassian.jira/jira-configurator

private void updateWebServerProfile(@Nonnull final Settings settings)
{
  final List<WebServerProfile> usableProfiles = WebServerProfile.getUsableProfiles(settings);
  cbWebServerProfile.setRenderer(new DisabledComboBoxRenderer(usableProfiles));
  cbWebServerProfile.setSelectedItem(settings.getWebServerProfile());
  cbWebServerProfile.setAction(new AbstractAction()
  {
    private WebServerProfile currentProfile = settings.getWebServerProfile();
    private List<WebServerProfile> usableProfile = usableProfiles;
    
    @Override
    public void actionPerformed(ActionEvent actionEvent)
    {
      final WebServerProfile selectedProfile = getWebServerProfile();
      if (usableProfile.contains(selectedProfile))
      {
        currentProfile = selectedProfile;
        updateWebServerConfigurationFields(selectedProfile);
      }
      else
      {
        cbWebServerProfile.setSelectedItem(currentProfile);
      }
    }
  });
  updateWebServerWarningLabel(settings.getComplexConfigurationReasons());
}

代码示例来源:origin: net.sf.ingenias/editor

resources.getCommonButtons().getJc().setAction(new AbstractAction("") {
  private boolean enabled = true;
  public void actionPerformed(ActionEvent e) {

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

add(selectionButton);
combo.setAction(selectionAction);

代码示例来源:origin: org.activecomponents.jadex/jadex-editor-bpmn

cobox.setAction(new AbstractAction()

代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core

this.monthBox.setAction(new MonthAction());
this.toolBar.add(this.monthBox);

代码示例来源:origin: tinyMediaManager/tinyMediaManager

cbWatched.setAction(actionFilter);
add(cbWatched, "6, 6, fill, default");
cbGenre.setAction(actionFilter);
add(cbGenre, "6, 7, fill, default");
cbCertification.setAction(actionFilter);
add(cbCertification, "6, 8, fill, default");
cbMovieset.setAction(actionFilter);
add(cbMovieset, "6, 12, fill, default");
cbVideoFormat.setAction(actionFilter);
add(cbVideoFormat, "6, 13, fill, default");
cbVideoCodec.setAction(actionFilter);
add(cbVideoCodec, "6, 14, fill, default");
cbAudioCodec.setAction(actionFilter);
add(cbAudioCodec, "6, 16, fill, default");
cbMediaSource.setAction(actionFilter);
add(cbMediaSource, "6, 18, fill, default");
cbOffline.setAction(actionFilter);
add(cbOffline, "6, 22, fill, default");
cbSortColumn.setAction(actionSort);
add(cbSortColumn, "2, 28, 3, 1, fill, default");

代码示例来源:origin: org.nuiton.jaxx/jaxx-swing-action

A action = newAction(actionKey, component);
component.setAction(action);
Integer val = (Integer) action.getValue("selectedIndex");
if (val != null && val != -1 && val < component.getItemCount() && val != component.getSelectedIndex()) {

代码示例来源:origin: tinyMediaManager/tinyMediaManager

cbWatched.setAction(actionFilter);
add(cbWatched, "6, 5, fill, default");
cbGenres.setAction(actionFilter);
add(cbGenres, "6, 6, fill, default");
cbVideoFormat.setAction(actionFilter);
add(cbVideoFormat, "6, 9, fill, default");
cbVideoCodec.setAction(actionFilter);
add(cbVideoCodec, "6, 10, fill, default");
cbAudioCodec.setAction(actionFilter);
add(cbAudioCodec, "6, 11, fill, default");
cbMediaSource.setAction(actionFilter);
add(cbMediaSource, "6, 13, fill, default");

相关文章

JComboBox类方法