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

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

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

JComboBox.putClientProperty介绍

暂无

代码示例

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

public MenuControl(String nodePath, Port port) {
  super(nodePath, port);
  setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
  menuBox = new JComboBox<>();
  menuModel = new MenuDataModel(port);
  MenuItemRenderer menuItemRenderer = new MenuItemRenderer();
  menuBox.setModel(menuModel);
  menuBox.setRenderer(menuItemRenderer);
  menuBox.putClientProperty("JComponent.sizeVariant", "small");
  menuBox.putClientProperty("JComboBox.isPopDown", Boolean.TRUE);
  menuBox.setFont(Theme.SMALL_BOLD_FONT);
  menuBox.addActionListener(this);
  add(menuBox);
  setValueForControl(port.getValue());
}

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

public FontControl(String nodePath, Port port) {
  super(nodePath, port);
  setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
  fontChooser = new JComboBox<>();
  fontModel = new FontDataModel();
  FontCellRenderer fontCellRenderer = new FontCellRenderer();
  fontChooser.setModel(fontModel);
  fontChooser.setRenderer(fontCellRenderer);
  fontChooser.putClientProperty("JComponent.sizeVariant", "small");
  fontChooser.setPreferredSize(new Dimension(150, 22));
  fontChooser.putClientProperty("JComboBox.isPopDown", Boolean.TRUE);
  fontChooser.addActionListener(this);
  fontChooser.setFont(Theme.SMALL_BOLD_FONT);
  add(fontChooser);
  setValueForControl(port.getValue());
}

代码示例来源:origin: org.trypticon.hex/hex-util

/**
 * Sets the given combo boxes to appear in the square style. Actually, on modern versions of Mac OS X,
 * combo boxes are this style by default - but it looks like setting this option adjusts the borders
 * of the combo box to line up better with other components like text fields.
 *
 * @param comboBoxes the combo boxes to make square.
 */
public static void makeSquare(JComboBox<?>... comboBoxes) {
  for (JComboBox<?> comboBox : comboBoxes) {
    comboBox.putClientProperty("JComboBox.isSquare", true);
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

static void setIgnoreSelectionEvents( JComboBox combo, boolean ignore ) {
  combo.putClientProperty( "nb.combo.autocomplete.ignoreselection", ignore ); //NOI18N
}

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

public DefaultCellEditor(final JComboBox comboBox) {
 editorComponent = comboBox;
 comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

public FmtBraces() {
  initComponents();
  classDeclCombo.putClientProperty(OPTION_ID, CLASS_DECL_BRACE_PLACEMENT);
  methodDeclCombo.putClientProperty(OPTION_ID, METHOD_DECL_BRACE_PLACEMENT);
  ifCombo.putClientProperty(OPTION_ID, IF_BRACE_PLACEMENT);
  forCombo.putClientProperty(OPTION_ID, FOR_BRACE_PLACEMENT);
  switchCombo.putClientProperty(OPTION_ID, SWITCH_BRACE_PLACEMENT);
  whileCombo.putClientProperty(OPTION_ID, WHILE_BRACE_PLACEMENT);
  catchCombo.putClientProperty(OPTION_ID, CATCH_BRACE_PLACEMENT);
  useTraitCombo.putClientProperty(OPTION_ID, USE_TRAIT_BODY_BRACE_PLACEMENT);
  otherCombo.putClientProperty(OPTION_ID, OTHER_BRACE_PLACEMENT);
}

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

JComboBox comboBox = new JComboBox(...);
comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
comboBox.addActionListener(...);

代码示例来源:origin: jsettlers/settlers-remake

private void setStyle() {
  readyButton.setSize(new Dimension(READY_BUTTON_WIDTH, READY_BUTTON_HEIGHT));
  readyButton.setMaximumSize(new Dimension(READY_BUTTON_WIDTH, READY_BUTTON_HEIGHT));
  readyButton.setPreferredSize(new Dimension(READY_BUTTON_WIDTH, READY_BUTTON_HEIGHT));
  readyButton.setMinimumSize(new Dimension(READY_BUTTON_WIDTH, READY_BUTTON_HEIGHT));
  playerNameLabel.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_DYNAMIC);
  teamComboBox.putClientProperty(ELFStyle.KEY, ELFStyle.COMBOBOX);
  slotComboBox.putClientProperty(ELFStyle.KEY, ELFStyle.COMBOBOX);
  typeComboBox.putClientProperty(ELFStyle.KEY, ELFStyle.COMBOBOX);
  civilisationComboBox.putClientProperty(ELFStyle.KEY, ELFStyle.COMBOBOX);
  updateReadyButtonStyle();
}

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

public ComboBoxCellEditor(JComboBox comboBox) {
  this.comboBox = comboBox;
  this.comboBox.putClientProperty(IS_TABLE_CELL_EDITOR_PROPERTY, Boolean.TRUE);
  // hitting enter in the combo box should stop cellediting (see below)
  this.comboBox.addActionListener(this);
  
  //  Editing should be stopped when textfield loses its focus
  //  otherwise the value may get lost (e.g. see CAY-1104)
  //  LATER: this turned out to be the wrong fix, so I commented 
  //  out the code in focusLost to fix CAY-1719 and fixed CAY-1104 differently.
  // this.comboBox.getEditor().getEditorComponent().addFocusListener(this);
  // remove the editor's border - the cell itself already has one
  ((JComponent) comboBox.getEditor().getEditorComponent()).setBorder(null);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-grailsproject

LibrariesCustomizerPanel(GrailsProjectProperties uiProperties) {
  this.uiProperties = uiProperties;
  initComponents();
  jComboBoxTarget.setModel(uiProperties.getJavaPlatformModel());
  jComboBoxTarget.setRenderer(uiProperties.getJavaPlatformRenderer());
  jComboBoxTarget.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);    //NOI18N
  jComboBoxTarget.addItemListener(new java.awt.event.ItemListener(){
    public void itemStateChanged(java.awt.event.ItemEvent e){
      javax.swing.JComboBox combo = (javax.swing.JComboBox)e.getSource();
      combo.setPopupVisible(false);
    }
  });
}

代码示例来源:origin: pentaho/pentaho-reporting

public PropertyEditorCellEditor() {
 this.tagsCellEditor = new JComboBox();
 this.tagsCellEditor.addActionListener( new SelectionAction() );
 this.tagsCellEditor.putClientProperty( "JComboBox.isTableCellEditor", Boolean.TRUE );
 this.tagsCellEditor.getInputMap().put( KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0 ), new CancelAction() );
 this.tagsCellEditor.setRenderer( new TagListComboBoxRenderer() );
 this.defaultCellEditor = new JTextField();
 this.defaultCellEditor.addActionListener( new SelectionAction() );
 this.defaultCellEditor.setBorder( BorderFactory.createEmptyBorder() );
}

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

/**
 * Ajout l'auto-complétion sur une liste déroulante, en utilisant le
 * converteur donné pour afficher les données.
 *
 * @param combo     la combo à décorer
 * @param convertor le converter utilisé pour afficher les données.
 */
public static void decorate(JComboBox combo, ObjectToStringConverter convertor) {
  // tchemit 2010-10-05 since swingx 1.6.2, undecorate stuff is no more
  // public and we want to use it, so hack it...
  combo.putClientProperty("oldEditor", combo.getEditor());
  combo.putClientProperty("oldDocument", combo.getEditor().getEditorComponent());
  AutoCompleteDecorator.decorate(combo, convertor);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project

@SuppressWarnings("unchecked")
private void initEncoding() {
  originalEncoding = ProjectPropertiesSupport.getEncoding(properties.getProject());
  if (originalEncoding == null) {
    originalEncoding = Charset.defaultCharset().name();
  }
  encodingComboBox.setRenderer(ProjectCustomizer.encodingRenderer());
  encodingComboBox.setModel(ProjectCustomizer.encodingModel(originalEncoding));
  final String lafid = UIManager.getLookAndFeel().getID();
  if (!"Aqua".equals(lafid)) { // NOI18N
     encodingComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); // NOI18N
     encodingComboBox.addItemListener(new ItemListener() {
      @Override
       public void itemStateChanged(ItemEvent e) {
         JComboBox combo = (JComboBox) e.getSource();
         combo.setPopupVisible(false);
       }
     });
  }
}

代码示例来源:origin: com.cedarsoft.commons/swing-presenter

@Override
protected void bind( @NotNull JComboBox presentation, @NotNull StructPart struct, @NotNull Lookup lookup ) {
 {
  PropertyCallback<Action> callback = new PropertyCallback<Action>( presentation, PROPERTY_ACTION, Action.class );
  lookup.bindWeak( callback );
  presentation.putClientProperty( KEY_ACTION_CALLBACK, callback );
 }
 //sets a renderer
 {
  PropertyCallback<ListCellRenderer> callback = new PropertyCallback<ListCellRenderer>( presentation, PROPERTY_RENDERER, ListCellRenderer.class );
  lookup.bindWeak( callback );
  presentation.putClientProperty( KEY_RENDERER_CALLBACK, callback );
 }
 if ( lookup.lookup( ListCellRenderer.class ) == null ) {
  presentation.setRenderer( new StructDefaultCellRenderer() );
 }
 //set the model
 presentation.setModel( new StructBasedComboBoxModel( struct ) );
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

public static boolean install( JComboBox combo ) {
  boolean res = false;
  ComboBoxEditor comboEditor = combo.getEditor();
  if( comboEditor.getEditorComponent() instanceof JTextComponent ) {
    JTextComponent textEditor = ( JTextComponent ) comboEditor.getEditorComponent();
    Document doc = textEditor.getDocument();
    doc.addDocumentListener( new AutoCompleteListener( combo ) );
    setIgnoreSelectionEvents( combo, false );
    combo.setEditable( true );
    res = true;
  }
  combo.putClientProperty( "nb.combo.autocomplete", res ); //NOI18N
  return res;
}

代码示例来源:origin: pentaho/pentaho-reporting

/**
 * Creates a new <code>JPanel</code> with a double buffer and a flow layout.
 */
public TagListTableCellEditor() {
 setLayout( new BorderLayout() );
 tags = EMPTY_TAGS;
 eventListenerList = new EventListenerList();
 comboBox = new JComboBox();
 comboBox.addActionListener( new SelectionAction() );
 comboBox.putClientProperty( "JComboBox.isTableCellEditor", Boolean.TRUE );
 comboBox.getInputMap().put( KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0 ), new CancelAction() );
 comboBox.setEditable( true );
 comboBox.setRenderer( new TagListComboBoxRenderer() );
 comboBox.setModel( new DefaultComboBoxModel( getTags() ) );
 comboBox.setEditable( true );
 add( comboBox, BorderLayout.CENTER );
 comboBox.requestFocus();
}

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

protected AutoCompletion(final JComboBox comboBox, boolean strict, boolean allowsUserValues) {
  this.comboBox = comboBox;
  textEditor = ((JTextComponent)comboBox.getEditor().getEditorComponent());
  this.allowsUserValues = allowsUserValues;
  suggestionList = new SuggestionList(comboBox, strict);
  // Marking combobox as auto-completing
  comboBox.putClientProperty(AUTOCOMPLETION_PROPERTY, Boolean.TRUE);
}

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

final JComboBox simpleBox = new JComboBox(Locale.getAvailableLocales());
 // this line configures the combo to only commit on ENTER 
 // or selecting an item from the list
 simpleBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
 //
 // simpleBox.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
 //     Collections.EMPTY_SET);
 // just noticed the OPs edit - following indeed is easier to disable _all_ traversal
 // keys with one statement
 simpleBox.setFocusTraversalKeysEnabled(false);
 Action myAction = new AbstractAction() {
   @Override
   public void actionPerformed(ActionEvent e) {
     LOG.info("got it!");
     simpleBox.transferFocus();
   }
 };
 simpleBox.getActionMap().put("tab-action", myAction);
 simpleBox.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
   .put(KeyStroke.getKeyStroke("TAB"), "tab-action");

代码示例来源:origin: com.haulmont.thirdparty/glazedlists

/**
 * This factory method creates and returns a {@link AutoCompleteCellEditor}
 * which adapts an autocompleting {@link JComboBox} for use as a Table
 * Cell Editor. The values within the <code>source</code> are used as
 * autocompletion terms within the {@link ComboBoxModel}.
 *
 * <p>If the appearance or function of the autocompleting {@link JComboBox}
 * is to be customized, it can be retrieved using
 * {@link AutoCompleteCellEditor#getComponent()}.
 *
 * @param source the source of data for the JComboBox within the table cell editor
 * @return a {@link AutoCompleteCellEditor} which contains an autocompleting
 *      combobox whose model contents are determined by the given <code>source</code>
 */
public static <E> AutoCompleteCellEditor<E> createTableCellEditor(EventList<E> source) {
  // build a special JComboBox used only in Table Cell Editors
  final JComboBox comboBox = new TableCellComboBox();
  comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
  // install autocompletion support on the special JComboBox
  final AutoCompleteSupport<E> autoCompleteSupport = AutoCompleteSupport.install(comboBox, source);
  autoCompleteSupport.setSelectsTextOnFocusGain(false);
  // create an AutoCompleteCellEditor using the AutoCompleteSupport object
  final AutoCompleteCellEditor<E> cellEditor = new AutoCompleteCellEditor<E>(autoCompleteSupport);
  cellEditor.setClickCountToStart(2);
  return cellEditor;
}

代码示例来源:origin: jsettlers/settlers-remake

private void setStyle() {
  mapNameLabel.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_LONG);
  numberOfPlayersLabel.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_SHORT);
  startResourcesLabel.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_SHORT);
  peaceTimeLabel.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_SHORT);
  titleLabel.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_HEADER);
  cancelButton.putClientProperty(ELFStyle.KEY, ELFStyle.BUTTON_MENU);
  startGameButton.putClientProperty(ELFStyle.KEY, ELFStyle.BUTTON_MENU);
  slotsHeadlinePlayerNameLabel.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_DYNAMIC);
  slotsHeadlineCivilisation.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_DYNAMIC);
  slotsHeadlineType.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_DYNAMIC);
  slotsHeadlineMapSlot.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_DYNAMIC);
  slotsHeadlineTeam.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_DYNAMIC);
  sendChatMessageButton.putClientProperty(ELFStyle.KEY, ELFStyle.BUTTON_MENU);
  chatInputField.putClientProperty(ELFStyle.KEY, ELFStyle.TEXT_DEFAULT);
  chatArea.putClientProperty(ELFStyle.KEY, ELFStyle.PANEL_DARK);
  startResourcesComboBox.putClientProperty(ELFStyle.KEY, ELFStyle.COMBOBOX);
  numberOfPlayersComboBox.putClientProperty(ELFStyle.KEY, ELFStyle.COMBOBOX);
  peaceTimeComboBox.putClientProperty(ELFStyle.KEY, ELFStyle.COMBOBOX);
  chatArea.putClientProperty(ELFStyle.KEY, ELFStyle.TEXT_DEFAULT);
  SwingUtilities.updateComponentTreeUI(this);
}

相关文章

JComboBox类方法