Package javax.swing

Examples of javax.swing.ComboBoxEditor


    if (nullableComboBox) {
      categoriesList.add(0, null);
    }
    this.categoryComboBox = new JComboBox(categoriesList.toArray());
    this.categoryComboBox.setEditable(true);
    final ComboBoxEditor defaultEditor = this.categoryComboBox.getEditor();
    // Change editor to edit category name
    this.categoryComboBox.setEditor(new ComboBoxEditor() {
        public Object getItem() {
          String name = (String)defaultEditor.getItem();
          name = name.trim();
          // If category is empty, replace it by the last selected item
          if (name.length() == 0) {
            setItem(nullableComboBox ? null : categoryComboBox.getSelectedItem());
          }
          FurnitureCategory category = new FurnitureCategory(name);
          // Search an existing category
          int categoryIndex = Collections.binarySearch(categories, category);
          if (categoryIndex >= 0) {
            return categories.get(categoryIndex);
          }
          // If no existing category was found, return a new one         
          return category;
        }
     
        public void setItem(Object value) {
          if (value != null) {
            FurnitureCategory category = (FurnitureCategory)value;
            defaultEditor.setItem(category.getName());
          }
        }

        public void addActionListener(ActionListener l) {
          defaultEditor.addActionListener(l);
        }

        public Component getEditorComponent() {
          return defaultEditor.getEditorComponent();
        }

        public void removeActionListener(ActionListener l) {
          defaultEditor.removeActionListener(l);
        }

        public void selectAll() {
          defaultEditor.selectAll();
        }
      });
    this.categoryComboBox.setRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index,
                                                      boolean isSelected, boolean cellHasFocus) {
View Full Code Here


   * Creates a editor for use with comboboxes.
   *
   * @return a combobox editor.
   */
  public ComboBoxEditor createComboBoxEditor() {
    return new ComboBoxEditor() {

      public void addActionListener(ActionListener l) {
        // Nope
      }

View Full Code Here

        ImportedFurnitureWizardStepsPanel.class, "categoryLabel.text"));
    this.categoryComboBox = new JComboBox(preferences.getFurnitureCatalog().getCategories().toArray());
    // The piece category isn't enabled by default for home furniture import
    this.categoryComboBox.setEnabled(!importHomePiece);
    this.categoryComboBox.setEditable(true);
    final ComboBoxEditor defaultEditor = this.categoryComboBox.getEditor();
    // Change editor to edit category name
    this.categoryComboBox.setEditor(new ComboBoxEditor() {
        public Object getItem() {
          String name = (String)defaultEditor.getItem();
          name = name.trim();
          // If category is empty, replace it by the last selected item
          if (name.length() == 0) {
            setItem(categoryComboBox.getSelectedItem());
          }
          FurnitureCategory category = new FurnitureCategory(name);
          // Search an existing category
          List<FurnitureCategory> categories = preferences.getFurnitureCatalog().getCategories();
          int categoryIndex = Collections.binarySearch(categories, category);
          if (categoryIndex >= 0) {
            return categories.get(categoryIndex);
          }
          // If no existing category was found, return a new one         
          return category;
        }
     
        public void setItem(Object value) {
          if (value != null) {
            FurnitureCategory category = (FurnitureCategory)value;
            defaultEditor.setItem(category.getName());
          }
        }

        public void addActionListener(ActionListener l) {
          defaultEditor.addActionListener(l);
        }

        public Component getEditorComponent() {
          return defaultEditor.getEditorComponent();
        }

        public void removeActionListener(ActionListener l) {
          defaultEditor.removeActionListener(l);
        }

        public void selectAll() {
          defaultEditor.selectAll();
        }
      });
    this.categoryComboBox.setRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index,
                                                      boolean isSelected, boolean cellHasFocus) {
View Full Code Here

    this.categoryLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
        ImportedTextureWizardStepsPanel.class, "categoryLabel.text"));
    this.categoryComboBox = new JComboBox(preferences.getTexturesCatalog().getCategories().toArray());
    this.categoryComboBox.setEditable(true);
    final ComboBoxEditor defaultEditor = this.categoryComboBox.getEditor();
    // Change editor to edit category name
    this.categoryComboBox.setEditor(new ComboBoxEditor() {
        public Object getItem() {
          String name = (String)defaultEditor.getItem();
          name = name.trim();
          // If category is empty, replace it by the last selected item
          if (name.length() == 0) {
            setItem(categoryComboBox.getSelectedItem());
          }
          TexturesCategory category = new TexturesCategory(name);
          // Search an existing category
          List<TexturesCategory> categories = preferences.getTexturesCatalog().getCategories();
          int categoryIndex = Collections.binarySearch(categories, category);
          if (categoryIndex >= 0) {
            return categories.get(categoryIndex);
          }
          // If no existing category was found, return a new one         
          return category;
        }
     
        public void setItem(Object value) {
          if (value != null) {
            TexturesCategory category = (TexturesCategory)value;         
            defaultEditor.setItem(category.getName());
          }
        }

        public void addActionListener(ActionListener l) {
          defaultEditor.addActionListener(l);
        }

        public Component getEditorComponent() {
          return defaultEditor.getEditorComponent();
        }

        public void removeActionListener(ActionListener l) {
          defaultEditor.removeActionListener(l);
        }

        public void selectAll() {
          defaultEditor.selectAll();
        }
      });
    this.categoryComboBox.setRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index,
                                                      boolean isSelected, boolean cellHasFocus) {
View Full Code Here

    final MultiStateButton  button      = b;
    final JComboBox      ggBlend      = new JComboBox(); // ( pcbm );
    final ListCellRenderer  blendRenderer  = getComboBoxRenderer();
   
    ggBlend.setEditable( true );
    ggBlend.setEditor( new ComboBoxEditor() {
      public Component getEditorComponent() { return button; }

      public void setItem( Object o )
      {
//System.err.println( "setItem " + o );
View Full Code Here

    });
  }

  @RunsInCurrentThread
  private static @Nullable Component editorComponent(@Nonnull JComboBox comboBox) {
    ComboBoxEditor editor = comboBox.getEditor();
    if (editor == null) {
      return null;
    }
    return editor.getEditorComponent();
  }
View Full Code Here

         * Implementation copied from BasicComboBoxUI.Handler.focusLost and
         * changed slightly as seen in the comments below.
         */
        public void focusLost(FocusEvent e) {
            if (e.getSource() == getEditor().getEditorComponent()) {
                final ComboBoxEditor editor = getEditor();
                final Object item = editor.getItem();

                if (!e.isTemporary() && item != null && !item.equals(getSelectedItem()))
                    actionPerformed(new ActionEvent(editor, 0, "", EventQueue.getMostRecentEventTime(), 0));
            }

View Full Code Here

    ellipsisButton = new EllipsisButton("...");
    ellipsisButton.addActionListener(action);

    comboBox = new JComboBox();
    final ComboBoxEditor boxEditor = comboBox.getEditor();
    if (boxEditor instanceof BasicComboBoxEditor)
    {
      final BasicComboBoxEditor basicComboBoxEditor = (BasicComboBoxEditor) boxEditor;
      final Object editorComponent = basicComboBoxEditor.getEditorComponent();
      if (editorComponent instanceof JTextField)
View Full Code Here

    textField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), CONFIRM_EDITOR);
    textField.getActionMap().put(CONFIRM_EDITOR, new SelectionAction());
    textField.setBorder(BorderFactory.createEmptyBorder());

    comboBox = new JComboBox();
    final ComboBoxEditor boxEditor = comboBox.getEditor();
    if (boxEditor instanceof BasicComboBoxEditor)
    {
      final BasicComboBoxEditor basicComboBoxEditor = (BasicComboBoxEditor) boxEditor;
      final Object editorComponent = basicComboBoxEditor.getEditorComponent();
      if (editorComponent instanceof JTextField)
View Full Code Here

      {
        harness.fail("Problem setting MetalLookAndFeel");
      }
   
    JComboBox c1 = new JComboBox(new Object[] {"A", "B", "C"});
    ComboBoxEditor editor = c1.getEditor();
   
    // check default value
    harness.check(editor instanceof MetalComboBoxEditor.UIResource);
   
    c1.setEditor(new MetalComboBoxEditor());
View Full Code Here

TOP

Related Classes of javax.swing.ComboBoxEditor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.