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

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

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

JComboBox.setFocusable介绍

暂无

代码示例

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

box.setRenderer(new ComboBoxListRenderer());
box.setForeground(Color.WHITE);
box.setFocusable(false);
box.setPrototypeDisplayValue("XXXXXXXX"); //sorry but this is the way to keep the size of the combobox in check.
try

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

public static void setupAutoComplete(final JTextField txtInput,final JTextField txtInput2, final ArrayList<String> items) {
    final DefaultComboBoxModel model = new DefaultComboBoxModel();
    final JComboBox cbInput = new JComboBox(model) {
      public Dimension getPreferredSize() {
        return new Dimension(super.getPreferredSize().width, 0);
      }
    };

    //The important line:
    cbInput.setFocusable(false);

    setAdjusting(cbInput, false);
    for (Object item : items) {
      model.addElement(item);
    }
    ...
}

代码示例来源:origin: com.projectdarkstar.client/sgs-tutorial-client

/**
 * {@inheritDoc}
 * <p>
 * This implementation adds a channel selector component next
 * to the input text field to allow users to choose between
 * direct-to-server messages and channel broadcasts.
 */
@Override
protected void populateInputPanel(JPanel panel) {
  super.populateInputPanel(panel);
  channelSelectorModel = new DefaultComboBoxModel();
  channelSelectorModel.addElement("<DIRECT>");
  channelSelector = new JComboBox(channelSelectorModel);
  channelSelector.setFocusable(false);
  panel.add(channelSelector, BorderLayout.WEST);
}

代码示例来源:origin: org.reddwarfserver.client/sgs-tutorial-client

/**
 * {@inheritDoc}
 * <p>
 * This implementation adds a channel selector component next
 * to the input text field to allow users to choose between
 * direct-to-server messages and channel broadcasts.
 */
@Override
protected void populateInputPanel(JPanel panel) {
  super.populateInputPanel(panel);
  channelSelectorModel = new DefaultComboBoxModel();
  channelSelectorModel.addElement("<DIRECT>");
  channelSelector = new JComboBox(channelSelectorModel);
  channelSelector.setFocusable(false);
  panel.add(channelSelector, BorderLayout.WEST);
}

代码示例来源:origin: antlr/antlrworks

public JComboBox createRulesPopUp() {
  rulesCombo = new JComboBox();
  rulesCombo.setFocusable(false);
  rulesCombo.setMaximumSize(new Dimension(Short.MAX_VALUE, rulesCombo.getPreferredSize().height));
  rulesCombo.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent event) {
      String rule = (String)rulesCombo.getSelectedItem();
      if(rule != null)
        startSymbol = rule;
    }
  });
  return rulesCombo;
}

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

JComboBox combo = new JComboBox(new Object[]{"Dog", "Cat", "Bird"});
combo.setBackground(Color.WHITE);
combo.setForeground(Color.BLACK);
combo.setFocusable(false);

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

@Override
  public void processDataBinding() {
    combobox.setFocusable(isEnabled() && isEditable());
  }
});

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

@Override
  public void processDataBinding() {
    combobox.setFocusable(isEnabled() && isEditable());
  }
});

代码示例来源:origin: antlr/antlrworks

public JComboBox createEOLCombo() {
  eolCombo = new JComboBox();
  eolCombo.setFocusable(false);
  eolCombo.setMaximumSize(new Dimension(Short.MAX_VALUE, eolCombo.getPreferredSize().height));
  Utils.fillComboWithEOL(eolCombo);
  return eolCombo;
}

代码示例来源:origin: nroduit/Weasis

private void addDisplayFormatComponent() {
    formatLabel = new JLabel(Messages.getString("ToolPanel.disp_format") + StringUtil.COLON); //$NON-NLS-1$
    this.add(formatLabel);

    formatCombo = new JComboBox<>(Format.values());
    formatCombo.setFocusable(false);
    formatCombo.setSelectedItem(view.getCurrentFormat());
    formatCombo.addActionListener(e -> view.setFormat((Format) formatCombo.getSelectedItem()));
    this.add(formatCombo);
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-mobility-svgcore

private void initCombo(JComponent bar, JComboBox comboBox) {
  GridBagConstraints constrains = new GridBagConstraints();
  constrains.anchor = GridBagConstraints.WEST;
  //@inherited fix of issue #69642. Focus shouldn't stay in toolbar
  comboBox.setFocusable(false);
  Dimension size = comboBox.getPreferredSize();
  comboBox.setPreferredSize(size);
  comboBox.setSize(size);
  comboBox.setMinimumSize(size);
  comboBox.setMaximumSize(size);
  comboBox.setEditable(true);
  bar.add(comboBox, constrains);
}

代码示例来源:origin: cpesch/RouteConverter

panel1.add(label3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
comboBoxZoom = new JComboBox();
comboBoxZoom.setFocusable(false);
panel1.add(comboBoxZoom, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
mapViewPanel = new JPanel();

代码示例来源:origin: nroduit/Weasis

private void init() {
  JLabel zoomLabel = new JLabel(Messages.getString("ToolPanel.zoom")); //$NON-NLS-1$
  this.add(zoomLabel);
  JComboBox<Speed> speed = new JComboBox<>(Speed.values());
  speed.addActionListener(e -> view.setSpeed(((Speed) speed.getSelectedItem()).getValue()));
  speed.setSelectedItem(Speed.fromValue(view.getSpeed()));
  speed.setFocusable(false);
  this.add(speed);
  JComboBox<Amplitude> amplitude = new JComboBox<>(Amplitude.values());
  amplitude.addActionListener(e -> view.setAmplitude(((Amplitude) amplitude.getSelectedItem()).getValue()));
  amplitude.setSelectedItem(Amplitude.fromValue(view.getAmplitude()));
  amplitude.setFocusable(false);
  this.add(amplitude);
  
  if (view.getChannelNumber() >= 12) {
    addDisplayFormatComponent();
  }
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

private JComponent makeThreadsPanel()
{
 JPanel panel = new JPanel( new BorderLayout() );
 _cbThreads = new JComboBox<>();
 _cbThreads.setBorder( BorderFactory.createMatteBorder( 1, 1, 1, 1, Scheme.active().getControlShadow() ) );
 _cbThreads.setRenderer( new ThreadCellRenderer( _cbThreads.getRenderer() ) );
 _cbThreads.addActionListener( action -> threadChanged() );
 _cbThreads.setFocusable( false );
 panel.add( _cbThreads, BorderLayout.NORTH );
 DefaultListModel<StackFrameRef> model = new DefaultListModel<>();
 _listFrames = new JList<>( model );
 _listFrames.setBackground( Scheme.active().getWindow() );
 _listFrames.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
 _listFrames.setFixedCellHeight( 22 );
 _listFrames.setCellRenderer( new StackFrameCellRenderer() );
 _listFrames.addListSelectionListener( e -> updateVars() );
 JScrollPane scroller = new JScrollPane( _listFrames );
 scroller.setBorder( null );
 panel.add( scroller, BorderLayout.CENTER );
 TabPane tabPane = new TabPane( TabPosition.TOP, TabPane.MINIMIZABLE | TabPane.RESTORABLE );
 tabPane.addTab( "Threads", EditorUtilities.loadIcon( "images/thread.png" ), panel );
 return tabPane;
}

代码示例来源:origin: org.biojava.thirdparty/forester

void startClickToOptions() {
  final JLabel spacer = new JLabel( "" );
  spacer.setFont( ControlPanel.jcb_font );
  add( spacer );
  _click_to_label = new JLabel( "Click on Node to:" );
  add( customizeLabel( _click_to_label, getConfiguration() ) );
  _click_to_combobox = new JComboBox<String>();
  _click_to_combobox.setFocusable( false );
  _click_to_combobox.setMaximumRowCount( 14 );
  _click_to_combobox.setFont( ControlPanel.js_font );
  if ( !_configuration.isUseNativeUI() ) {
    _click_to_combobox.setBackground( getConfiguration().getGuiBackgroundColor() );
  }
  // don't add listener until all items are set (or each one will trigger
  // an event)
  // click_to_list.addActionListener(this);
  add( _click_to_combobox );
  // Correlates option names to titles
  _all_click_to_names = new HashMap<Integer, String>();
  _click_to_names = new ArrayList<String>();
}

代码示例来源:origin: org.gdl-lang.gdl-tools/cds-gui-swing

private static void disable(JComboBox comboBox) {
  comboBox.setFocusable(false);
  comboBox.setUI(new DisabledComboUI());
  comboBox.setFont(comboBox.getFont().deriveFont(Font.PLAIN));
  ComboBoxEditor editor = comboBox.getEditor();
  if (editor != null && editor.getEditorComponent() instanceof JTextComponent) {
    ((JTextComponent) editor.getEditorComponent()).setEditable(false);
  }
}

代码示例来源:origin: org.gdl-lang.gdl-tools/cds-gui-swing

private static void enable(JComboBox component) {
  component.setFocusable(true);
  component.setUI((ComboBoxUI) UIManager.getUI(component));
  ComboBoxEditor editor = component.getEditor();
  if (editor != null && editor.getEditorComponent() instanceof JTextComponent) {
    ((JTextComponent) editor.getEditorComponent()).setEditable(true);
  }
}

代码示例来源:origin: org.biojava.thirdparty/forester

public JComboBox<String> getSequenceRelationBox() {
  if ( _show_sequence_relations == null ) {
    _show_sequence_relations = new JComboBox<String>();
    _show_sequence_relations.setFocusable( false );
    _show_sequence_relations.setMaximumRowCount( 20 );
    _show_sequence_relations.setFont( ControlPanel.js_font );
    if ( !_configuration.isUseNativeUI() ) {
      _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
      _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
    }
    _show_sequence_relations.addItem( "-----" );
    _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
  }
  return _show_sequence_relations;
}

代码示例来源:origin: org.gdl-lang.gdl-tools/openehr-utils-gui-swing

private JComboBox getUnitsComboBox() {
  if (unitsComboBox == null) {
    unitsComboBox = new JComboBox<>();
    unitsComboBox.setPreferredSize(new Dimension(70, 20));
    Units units = archetypeManager.getUnits();
    for (String unit : units.getUnits(getIdTemplate(), getIdElement())) {
      unitsComboBox.addItem(unit);
    }
    if (!enableUnits) {
      unitsComboBox.setFocusable(false);
      unitsComboBox.setUI(new DisabledComboUI());
      ComboBoxEditor editor = unitsComboBox.getEditor();
      if (editor != null && editor.getEditorComponent() instanceof JTextComponent) {
        ((JTextComponent) editor.getEditorComponent()).setEditable(false);
      }
    }
  }
  return unitsComboBox;
}

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

DELETE_RULES,
    false);
deleteRulesCombo.setFocusable(false);
deleteRulesCombo.setEditable(true);
((JComponent) deleteRulesCombo.getEditor().getEditorComponent()).setBorder(null);

相关文章

JComboBox类方法