• 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

Display layer below JComboBox

 
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have an implementation of searchable JComboBox that extends from JComboBox. Right now the combo box only searches for the first occurance of matched string, I want to get the whole set of matches. The logic stuff works, but how does GUI? I am thinking of putting found data in JList and making it visible, but should I put JList in the frame and make frame visible when action listener is fired? If yes, how can I calculate so that JList appears directly below JComboBox? Can I use JComboBox's own JList (the one that appears when user wants to see contents of JComboBox) as my temporary component for found matches?
Also, is there a way to display JFrame without any titles or status bars?

thanks a lot,
Alex
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
should I put JList in the frame
You could. You might also consider using a JDialog, JOptionPane or a JPopupMenu.

is there a way to display JFrame without any titles or status bars
Look in the JFrame api, scroll down below the Method Summary section to Methods inherited from class java.awt.Frame for the setUndecorated method. Follow the link to see what it does.

how can I calculate so that JList appears directly below JComboBox?
see Methods inherited from class java.awt.Component in JFrame api


Can I use JComboBox's own JList (the one that appears when user wants to see contents of JComboBox) as my temporary component for found matches?
Possibly, depends on what you want to do.
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excellent!
I looked in JComboBox API and there are couple of methods there that come really handy to what I am doing: showPopup() and hidePopup() these two bring up and hide the actual JComboBox's list. So I use this list to populate my results when JComboBox is being searched, and populate it back with all items when something was selected from the matches. Works really nice. The only thing that might be a problem is that I populate JComboBox with adding each item in a for loop, when JComboBox will have a lot of items, looping might take some time to finish, I think I will use ComboBoxModel to setModel of the combo box. Otherwise works like a charm.

thanks,
Alex
 
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic