1

The default Combobox in Mac OS is as follows:

http://dl.dropbox.com/u/10836207/Screen%20shot%202011-08-05%20at%209.53.48%20AM.png

How can I change to following one?:

http://dl.dropbox.com/u/10836207/Screen%20shot%202011-08-05%20at%209.54.01%20AM.png

P.S. - The Combobox is created in JTable.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Nick
  • 21
  • 1

2 Answers2

1

Check out the brilliant MacWidgets

Here are the key steps:

  1. Create a JComboBox with the appropriate L&F.
  2. Create a TableCellEditor with the comboBox, for example using DefaultCellEditor
  3. Set the editor on your JTable using setDefaultEditor(...)

TableCellRenderer getDefaultRenderer(Class columnClass)

Dilum Ranatunga
  • 13,254
  • 3
  • 41
  • 52
  • +1 for MacWidgets, although I'm not sure a renderer alone in sufficient. – trashgod Aug 05 '11 at 15:51
  • Hi, If I follow your step, it will create the first Combobox in my question. I need some way to get the second one. – Nick Aug 12 '11 at 13:19
  • I would start looking into the L&F. I suspect it has two different looks based on the container... – Dilum Ranatunga Aug 12 '11 at 14:55
  • One thing I should have made clear initially is that I want my Jcombobox to appear this way inside a jtable. The default look is very similar to a text cell inside a jtable, with the difference being that when you click the cell with the combobox a drop down arrow appears in the right hand side of the cell and clickable choices appear below. What I want is for the drop down arrow of the jcombobox to ALWAYS be visible. I know this is possible because I have seen examples of this in netbeans guibuilder properties panel. – Nick Aug 15 '11 at 13:41
1

The default UI delegate for JComboBox on Mac OS X is com.apple.laf.AquaComboBoxUI. You can replace it with your own variation of BasicComboBoxUI. There's a related example here and a more complete example in the MacWidgets collection suggested by @Dilum.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045