/** * Paints the current value along with the human readable name. * * @param graphics the graphics on which to paint. */ protected void paintComponent( final Graphics graphics ) { if ( color != null ) { setBackground( color ); graphics.setColor( color ); graphics.fillRect( 0, 0, getWidth(), getHeight() ); final int r = color.getRed(); final int g = color.getGreen(); final int b = color.getBlue(); int brightness = ( r > g ) ? r : g; if ( b > brightness ) { brightness = b; } if ( brightness > 167 ) { setForeground( Color.black ); } else { setForeground( Color.white ); } } super.paintComponent( graphics ); } }
if ( item != null ) { this.color = item; setBackground( item ); setText( ColorUtility.toAttributeValue( item ) ); return this; setText( Messages.getInstance().getString( "ColorCellRenderer.Automatic" ) ); setBackground( null ); return this;
/** * 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 ); }
setBackground( item ); setText( ColorUtility.toAttributeValue( item ) ); return this; setText( Messages.getInstance().getString( "ColorCellRenderer.Automatic" ) ); setBackground( null ); return this;