开发者

java swing display search result in a popup under JTextField "like facebook search"

I'm trying to simulate in java swing the same search results preview on facebook, but in java I suppose it'll gonna be :

  • JTextField : the user input goes here
  • JList : containing JList of JPanels ( results )
  • a popup or some container to hold the JList

The problem is, I couldn't manage how to display a popup right under the JTextField,开发者_运维技巧 I tried swingx autocomplete, editable combo box , glazedlists ... but it's not giving me good results

Can anyone help me please ?


When specifying the point of the popup, pre-calculate (hardcode) or dynamically calculate the location of the bottom left corner of the text field. Use that value or that value plus a few pixels lower as your location for your popup.


Without knowing more about the requirements, I'd suggest looking into JWindow


I was so pissed of to not be able to find a pre-made class or a .jar that can do what I wanted, so I made my own, in fact I used JWindow, and I made my own Drop Down JTextField menu that extends JTextField ! easy to use : vertical list of JPanels with the same width as the JTextField is drawn and refreshed to display suggestions each time the user enter a new character in the JTextField, then the user can choose ( or not ) between these suggestion by keyboard arrow keys UP and DOWN or by a mouse click ... and we can simply specify if we want to use a document filter for filtering the user's input ( like we wanna just get numerical values in JTextField ) ... and so many other stuff : it rocks !

I'll gladly share this class on the net, I just need some time to write some tutos and examples, but for now, here's two screenshots of what I made one uses Gradient color in a JPanel, and the other one uses the default background color,( don't mind the French JLabels )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜