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
All right brain, you don't like me and I don't like you, but let's just do this one thing so I can get back to killing you with beer.<br /> <br />- Homer Simpson
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.
Joined: Jan 24, 2001
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.