Use Synth to style a JComboBox when it's hovered/clicked?

55 Views Asked by At

I have defined a style in an XML file for JComboBox components, but the states PRESSED and MOUSE_OVER do not at any point do anything.

<style id="comboBoxStyle">
    <state> <!-- Normal state for combo box -->
        <color value="#9DA5B4" type="TEXT_FOREGROUND"/>
        <imagePainter method="comboBoxBackground" path="images/combobox.png" sourceInsets="2 2 2 2"/>
    </state>
    <state value="DISABLED"> <!-- Disabled state for combo box -->
        <color value="#6B717D" type="TEXT_FOREGROUND"/>
        <imagePainter method="comboBoxBackground" path="images/combobox_disabled.png" sourceInsets="2 2 2 2"/>
    </state>
    <state value="PRESSED"> <!-- Pressed state for combo box -->
        <color value="#DBDBDB" type="TEXT_FOREGROUND"/>
        <imagePainter method="comboBoxBackground" path="images/combobox_pressed.png" sourceInsets="2 2 2 2"/>
    </state>
    <state value="MOUSE_OVER"> <!-- Hovered state for combo box -->
        <color value="#DBDBDB" type="TEXT_FOREGROUND"/>
        <imagePainter method="comboBoxBackground" path="images/combobox_hovered.png" sourceInsets="2 2 2 2"/>
    </state>
</style>
<bind style="comboBoxStyle" type="region" key="ComboBox"/>

This is because they're not supposed to - in SynthComboBoxUI when it determines the state, only either ENABLED, DISABLED or FOCUSED are returned.

So my question is this - how can I make it so that the state for combo boxes can actually be PRESSED and MOUSE_OVER, therefore making the states defined in the XML file work?

I don't really know where to even start, I can't find anything helpful on the internet, so any help would be greatly appreciated.

0

There are 0 best solutions below