• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Need help creating custom ComboBoxEditor

 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has anyone ever created a custom ComboBoxEditor to display JLabels w/ icons in a JComboBox? I'm looking at the methods in the ComboBoxEditor interface, but I'm not sure how to override getEditorComponent() to return what I want.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should be looking more at the setRenderer( ListCellRenderer ) method... The ListCellRenderer renders the choices in the pull down combo box list. The ComboBoxEditor renders the editing area in an editable combo box. If you do override ListCellRenderer to show an icon and text in a JLabel, then you can override ComboBoxEditor to be a JPanel that holds a JLabel with an icon and a JTextField to edit the text...

Here's a short program that shows this...



-Nate
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the great reply! You've been a big help.
---Matt
 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic