• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

JComboBox and ListCellRenderer Problem

 
Ranch Hand
Posts: 153
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am trying to use a JComboBox with a simple ListCellRenderer





The JCombox shows and odd behavior, when I point to an item it moves up or down and an empty line appears under the cursor.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have an answer, just a couple of suggestions:
  • Compare your code with class javax.swing.DefaultListCellRenderer
  • Make your class extend javax.swing.DefaultCellRenderer
  •  
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Markus, try this… (I'm guessing your example doesn't work because by default JLabel is not opaque, so it won't show a background.)



    You can also use the UIManager and override the selection background color for all combo boxes. Just make sure you "put" the ColorUIResource into the defaults before you display your first window.

     
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!