/** * Defines the selected value without fireing a action event. * * @param o the new selected value. */ public void setValueFromModel( final Color o ) { final Action old = getAction(); setAction( null ); setSelectedItem( o ); setAction( old ); }
/** * Returns the currently selected value from the model, or null if no value is selected. * * @return the selected color. */ public Color getValueFromModel() { return (Color) getSelectedItem(); } }
/** * Creates a new color combobox and populates it with the excel colors. */ public ColorComboBox() { final DefaultComboBoxModel model = new DefaultComboBoxModel( ColorUtility.getPredefinedExcelColors() ); model.insertElementAt( null, 0 ); model.setSelectedItem( null ); setModel( model ); setRenderer( new ColorCellRenderer() ); final int height1 = getPreferredSize().height; setMaximumSize( new Dimension( height1 * 4, height1 ) ); setFocusable( false ); setEditable( false ); }