• 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
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JComboBox Problem

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I try to make the text field of a JComboBox transparent with this code:


but it doesn't do the Job.

I also would like to make the drop down list of the JComboBox transparent, but don't know how to retrieve the list object.

Any help is highly appreciated.

Stephan
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well textfield can be made transparent(also editable) by invoking the setEditable method...am also trying to make the dropdown list transparent.You could try this:


The problem with this is even the button on the combobox becomes white.I want the button to be visible in the default color and the textfield and dropdown list in white[like the one present on this very page ].Someone please let me know if its possible.

Thanks,
Thejaswini.

[ January 11, 2006: Message edited by: thejaswini ramesh ]
[ January 11, 2006: Message edited by: thejaswini ramesh ]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> I try to make the text field of a JComboBox transparent with this code:

try this

 
Stephan Bardubitzki
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Micheal,

this is doing the job:


I have the text field transparent, but unfortunately the button changed its L&F. Is there a way to avoid this?
 
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
it is these lines that do most of the transparency
cbo.setOpaque(false);
((JTextField)cbo.getEditor().getEditorComponent()).setOpaque(false);

changing the UI to basic gets rid of the textfield border(?), so it appears 'seemless'.
actually, you only need to do this
cbo.setUI(new BasicComboBoxUI());

perhaps if you experimented with the textfield's border, you may get what
you're after
 
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
see if this is any closer to what you want

 
Stephan Bardubitzki
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Michael!

Your code sample works very well for my use case.

Stephan
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic