Пользовательский интерфейс JComboBox состоит из текстового поля, списка и стрелок.
Чтобы настроить их, вы можете использовать готовый L & F или реализовать свой самый простой с Synth L & F.
Инициализация L & F:
SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();
try {
lookAndFeel.load(YourClassAlongWithSynthXml.class.getResourceAsStream("synth.xml"), YourClassAlongWithSynthXml.class);
} catch (ParseException e) {
e.printStackTrace();
}
UIManager.setLookAndFeel(lookAndFeel);
Где synth.xml содержит что-то вроде этого:
<style id="textfield">
<insets top="4" left="6" bottom="4" right="6" />
<state>
<font name="Verdana" size="12" />
<!--
<color type="BACKGROUND" value="#D2DFF2" />
-->
<color type="TEXT_FOREGROUND" value="#003c2d" />
</state>
<imagePainter method="textFieldBorder" path="images/textfield.png" sourceInsets="4 6 4 6" paintCenter="false" />
</style>
<bind style="textfield" type="region" key="TextField" />
<style id="arrowStyle">
<imagePainter method="arrowButtonForeground" path="images/arrow-up.png" sourceInsets="0 0 0 0" stretch="false" direction="north" />
<imagePainter method="arrowButtonForeground" path="images/arrow-down.png" sourceInsets="0 0 0 0" stretch="false" direction="south" />
<imagePainter method="arrowButtonForeground" path="images/arrow-left.png" sourceInsets="0 0 0 0" stretch="false" direction="west" />
<imagePainter method="arrowButtonForeground" path="images/arrow-right.png" sourceInsets="0 0 0 0" stretch="false" direction="east" />
</style>
<bind key="ArrowButton" type="region" style="arrowStyle" />
<style id="comboArrowStyle">
<imagePainter method="arrowButtonForeground" path="images/combobox-arrow.png" sourceInsets="0 0 0 0" stretch="false" direction="south" />
</style>
С Synth L & F вам нужно будет полностью определить, как ваши компоненты пользовательского интерфейса выглядят так, как вы не можете просто.
Но если вам просто нужно просто изменить цвета, используя L & F по умолчанию, вы можете использовать следующие фрагменты для инициализации интерфейса комбинированного окна:
final Color COLOR_BUTTON_BACKGROUND = Color.decode("#d3dedb");
UIManager.put("ComboBox.buttonBackground", COLOR_BUTTON_BACKGROUND);
UIManager.put("ComboBox.buttonShadow", COLOR_BUTTON_BACKGROUND);
UIManager.put("ComboBox.buttonDarkShadow", COLOR_BUTTON_BACKGROUND);
UIManager.put("ComboBox.buttonHighlight", COLOR_BUTTON_BACKGROUND);