• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
Bartenders:
  • Himai Minh
  • Carey Brown
  • Frits Walraven

Get the icon from the JComboBox button

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BasicArrowButton()
 
Bobby Anderson
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3244
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Look! I laid an egg! Why does it smell like that? Tiny ad, does this smell weird to you?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic