3

I have a editable combobox, but I am not able to change its background color. Tried

((JTextField) myJComboBox.getEditor().getEditorComponent())
#setBackground(Color.xxxx);

ref: Change JComboBox colours WITHOUT renderer

But it doesn't seem to work

Any ideas?

Community
  • 1
  • 1
Akash
  • 4,956
  • 11
  • 42
  • 70
  • my idea is, that there ...., be sure with that, that there must be another problem, – mKorbel Sep 20 '11 at 18:36
  • 2
    just changed tt.setOpaque(true); and it seems to work fine – Akash Sep 20 '11 at 18:42
  • my curiosity, for why reason(s) you set Opacity, and for which of JComponents from JComboBox, because JComboBox have got lots of JComponents – mKorbel Sep 20 '11 at 18:45
  • was set for JComponent, JTextField editorJComp = (JTextField); menuitems[i].getEditor().getEditorComponent(); editorJComp.setBackground(Color.red); editorJComp.setOpaque(true); – Akash Sep 20 '11 at 18:50
  • 3
    See also [opacity](http://java.sun.com/products/jfc/tsc/articles/painting/index.html#props). – trashgod Sep 20 '11 at 22:06
  • 2
    as far as I know, you can answer and accept your own question if you found a solution - more useful for others than to hide it in comments, IMO :-) – kleopatra Sep 21 '11 at 06:54

0 Answers0