Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Get the icon from the JComboBox button  RSS feed

 
Bobby Anderson
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to use the icon from the JComboBox for another custom component. How do I get the icon that is being used with my current L&F. My guess is that I can ask the UIManager, but I am not sure what key to use. If it is in fact a property in the UIManager is there somewhere where these properties are listed so I can look for them in the future without having to post a question.

Thanks,
Billy
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BasicArrowButton()
 
Bobby Anderson
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that what every look and feel uses? Shouldn't there be a way to get this from the combobox?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Is that what every look and feel uses?

no idea.


> Shouldn't there be a way to get this from the combobox?

it's not an image, open up the source file for BasicArrowButton and see how it's done.
 
Rob Camick
Ranch Hand
Posts: 2753
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is in fact a property in the UIManager is there somewhere where these properties are listed so I can look for them in the future without having to post a question.


Its not a property, but the UIManager Defaults will show you all the properties.
 
Bobby Anderson
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One problem I am having is that I want the button and colors from the JComboBox. If I just instantiate a default BasicArrowButton I don't get the right color.

The other issue is that I have an API that takes an icon, not a component. So is their really no way to make this look like the arrow on a JComboBox.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
perhaps a hack might be to create another comboBox (hidden),
then get a reference to the button via the combo ui's createArrowButton(),
and add that button to your frame.

you would need to
- remove all listeners (or override installListeners), adding your own
- cast to the correct ui
- probably also need to give the arrowButton a preferredSize

in theory, the button should look the same as your other visible comboBox arrowButton.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!