This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Modern JavaScript for the Impatient and have Cay Horstmann on-line!
See this thread for details.
Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JComboBox: Opaque problem

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anybody know why, when I setOpaque(false) to the renderer of my JComboBox, the selection works wrong(selected row is completely white). I tried to set Background and Foreground color - didn't work. Actually, setting the Foreground to black is fine, but in that case the selected row Background doesn't work.
Thanks in advance.
 
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> renderer of my JComboBox,
renderer of JComboBox ? AFAIK, there is no renderer in JComboBox. Can you please explain in detail ? Are you talking about JTable ?

[This message has been edited by Sankar Subbiah (edited July 09, 2001).]
 
Gene Kaplun
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sankar,
Thanks for your response. Here is my code:
public class LabelTypeComboBox extends ClearableComboBox{
public LabelTypeComboBox(){
super();
setRenderer(new DefaultListCellRenderer() {
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus){
DefaultListCellRenderer defRend = (DefaultListCellRenderer)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
//defRend.setOpaque(false);
return defRend;
}
});
I checked the bug database on the Sun. They say that some L&F don�t support setting �Opaque� property of the JcomboBox to False, yet I have a problem only with this particular ComboBox. All others work fine having the same renderers. When Opaque is true the selection works fine whereas my cool combobox's header ( I have moderntheme L&F) gets replaced by a regular white rectangle. If I change Opaque to false the header of the combobox looks fine, but list selection uses white background color and the selected line becomes invisible. I tried to change the Background and Foreground color. Doesn't work.
Thanks again.
 
San Su
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

How did i miss "setRenderer" method...
Gene Kaplun, I will try this today evening and let you know
the result.
 
Gene Kaplun
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sankar,
Thanks a lot for your concern. I found the solution.
setOpaque(isSelected ? true : false);
Best regards,
Gene
 
I would challenge you to a battle of wits, but I see you are unarmed - shakespear. Unarmed tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic