80 |
* UI Delegate for JComboBox |
* UI Delegate for JComboBox |
81 |
* |
* |
82 |
* @author Olga Rodimina |
* @author Olga Rodimina |
83 |
|
* @author Robert Schuster |
84 |
*/ |
*/ |
85 |
public class BasicComboBoxUI extends ComboBoxUI |
public class BasicComboBoxUI extends ComboBoxUI |
86 |
{ |
{ |
784 |
{ |
{ |
785 |
Object currentValue = comboBox.getSelectedItem(); |
Object currentValue = comboBox.getSelectedItem(); |
786 |
boolean isPressed = arrowButton.getModel().isPressed(); |
boolean isPressed = arrowButton.getModel().isPressed(); |
787 |
if (currentValue != null) |
|
788 |
{ |
/* Gets the component to be drawn for the current value. |
789 |
Component comp = comboBox.getRenderer() |
* If there is currently no selected item we will take an empty |
790 |
|
* String as replacement. |
791 |
|
*/ |
792 |
|
Component comp = comboBox.getRenderer() |
793 |
.getListCellRendererComponent(listBox, |
.getListCellRendererComponent(listBox, |
794 |
currentValue, |
(currentValue != null ? currentValue : ""), |
795 |
-1, |
-1, |
796 |
isPressed, |
isPressed, |
797 |
hasFocus); |
hasFocus); |
798 |
if (! comboBox.isEnabled()) |
if (! comboBox.isEnabled()) |
799 |
comp.setEnabled(false); |
comp.setEnabled(false); |
800 |
|
|
801 |
g.translate(borderInsets.left, borderInsets.top); |
g.translate(borderInsets.left, borderInsets.top); |
802 |
comp.setBounds(0, 0, bounds.width, bounds.height); |
comp.setBounds(0, 0, bounds.width, bounds.height); |
803 |
comp.paint(g); |
comp.paint(g); |
804 |
g.translate(-borderInsets.left, -borderInsets.top); |
g.translate(-borderInsets.left, -borderInsets.top); |
805 |
} |
|
806 |
comboBox.revalidate(); |
comboBox.revalidate(); |
807 |
} |
} |
808 |
else |
else |