Methods Summary |
---|
public void | configureEditor()
super.configureEditor();
editor.setBackground( UIManager.getColor( "text" ) );
|
protected java.awt.LayoutManager | createLayoutManager()
return new ComboBoxLayoutManager();
|
protected javax.swing.plaf.basic.ComboPopup | createPopup()
return new MotifComboPopup( comboBox );
|
protected java.beans.PropertyChangeListener | createPropertyChangeListener(){@inheritDoc}
return new MotifPropertyChangeListener();
|
public static javax.swing.plaf.ComponentUI | createUI(javax.swing.JComponent c)
return new MotifComboBoxUI();
|
public java.awt.Dimension | getMinimumSize(javax.swing.JComponent c)
if ( !isMinimumSizeDirty ) {
return new Dimension( cachedMinimumSize );
}
Dimension size;
Insets insets = getInsets();
size = getDisplaySize();
size.height += insets.top + insets.bottom;
int buttonSize = iconAreaWidth();
size.width += insets.left + insets.right + buttonSize;
cachedMinimumSize.setSize( size.width, size.height );
isMinimumSizeDirty = false;
return size;
|
public int | iconAreaWidth()
if ( comboBox.isEditable() )
return arrowIcon.getIconWidth() + (2 * HORIZ_MARGIN);
else
return arrowIcon.getIconWidth() + (3 * HORIZ_MARGIN) + 2;
|
protected void | installComponents()
if ( comboBox.isEditable() ) {
addEditor();
}
comboBox.add( currentValuePane );
|
public void | installUI(javax.swing.JComponent c)
super.installUI(c);
arrowIcon = new MotifComboBoxArrowIcon(UIManager.getColor("controlHighlight"),
UIManager.getColor("controlShadow"),
UIManager.getColor("control"));
Runnable initCode = new Runnable() {
public void run(){
if ( motifGetEditor() != null ) {
motifGetEditor().setBackground( UIManager.getColor( "text" ) );
}
}
};
SwingUtilities.invokeLater( initCode );
|
private java.awt.Component | motifGetEditor()
return editor;
|
public void | paint(java.awt.Graphics g, javax.swing.JComponent c)
boolean hasFocus = comboBox.hasFocus();
Rectangle r;
if (comboBox.isEnabled()) {
g.setColor(comboBox.getBackground());
} else {
g.setColor(UIManager.getColor("ComboBox.disabledBackground"));
}
g.fillRect(0,0,c.getWidth(),c.getHeight());
if ( !comboBox.isEditable() ) {
r = rectangleForCurrentValue();
paintCurrentValue(g,r,hasFocus);
}
r = rectangleForArrowIcon();
arrowIcon.paintIcon(c,g,r.x,r.y);
if ( !comboBox.isEditable() ) {
Border border = comboBox.getBorder();
Insets in;
if ( border != null ) {
in = border.getBorderInsets(comboBox);
}
else {
in = new Insets( 0, 0, 0, 0 );
}
// Draw the separation
if(MotifGraphicsUtils.isLeftToRight(comboBox)) {
r.x -= (HORIZ_MARGIN + 2);
}
else {
r.x += r.width + HORIZ_MARGIN + 1;
}
r.y = in.top;
r.width = 1;
r.height = comboBox.getBounds().height - in.bottom - in.top;
g.setColor(UIManager.getColor("controlShadow"));
g.fillRect(r.x,r.y,r.width,r.height);
r.x++;
g.setColor(UIManager.getColor("controlHighlight"));
g.fillRect(r.x,r.y,r.width,r.height);
}
|
public void | paintCurrentValue(java.awt.Graphics g, java.awt.Rectangle bounds, boolean hasFocus)
ListCellRenderer renderer = comboBox.getRenderer();
Component c;
Dimension d;
c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
c.setFont(comboBox.getFont());
if ( comboBox.isEnabled() ) {
c.setForeground(comboBox.getForeground());
c.setBackground(comboBox.getBackground());
}
else {
c.setForeground(UIManager.getColor("ComboBox.disabledForeground"));
c.setBackground(UIManager.getColor("ComboBox.disabledBackground"));
}
d = c.getPreferredSize();
currentValuePane.paintComponent(g,c,comboBox,bounds.x,bounds.y,
bounds.width,d.height);
|
protected java.awt.Rectangle | rectangleForArrowIcon()
Rectangle b = comboBox.getBounds();
Border border = comboBox.getBorder();
Insets in;
if ( border != null ) {
in = border.getBorderInsets(comboBox);
}
else {
in = new Insets( 0, 0, 0, 0 );
}
b.x = in.left;
b.y = in.top;
b.width -= (in.left + in.right);
b.height -= (in.top + in.bottom);
if(MotifGraphicsUtils.isLeftToRight(comboBox)) {
b.x = b.x + b.width - HORIZ_MARGIN - arrowIcon.getIconWidth();
}
else {
b.x += HORIZ_MARGIN;
}
b.y = b.y + (b.height - arrowIcon.getIconHeight()) / 2;
b.width = arrowIcon.getIconWidth();
b.height = arrowIcon.getIconHeight();
return b;
|
protected java.awt.Rectangle | rectangleForCurrentValue()
int width = comboBox.getWidth();
int height = comboBox.getHeight();
Insets insets = getInsets();
if(MotifGraphicsUtils.isLeftToRight(comboBox)) {
return new Rectangle(insets.left, insets.top,
(width - (insets.left + insets.right)) -
iconAreaWidth(),
height - (insets.top + insets.bottom));
}
else {
return new Rectangle(insets.left + iconAreaWidth(), insets.top,
(width - (insets.left + insets.right)) -
iconAreaWidth(),
height - (insets.top + insets.bottom));
}
|
protected void | uninstallComponents()
removeEditor();
comboBox.removeAll();
|