File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Character based Search Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Character based Search" Watch "Character based Search" New topic

Character based Search

sharjeel afzal

Joined: Sep 30, 2009
Posts: 22

I am developing a java desktop application
I want when some one starting to enter a character in textfield all the names starting from that character should shown in a list below
When he enter the second character search is based on 2 characters all names starting from that two charcters should be displayed in list user can select one
from list

How i achieve this thing in java (How to open drop down help)
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3152

You can listen for the KeyTyped event of the JTextField. And then use getText() to get the String typed. You can add a JComboBox and populate the entries to this drop down depending on your search criteria.

By the way- There's s Swing/AWT Forum where you can post queries related to Swing/AWT/JFace.

Mohamed Sanaulla | My Blog
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2450
Use a DocumentListener so you are notified when any change is made to the Document (either insertions or deletions).

Mark O'Neal

Joined: Jul 23, 2009
Posts: 5
This might be what you are looking for.

sharjeel afzal

Joined: Sep 30, 2009
Posts: 22
Thank you very much Mark O'Neal
sharjeel afzal

Joined: Sep 30, 2009
Posts: 22
I try this code

but it required to show and hide frame else popUp cannot hide

any help
I agree. Here's the link:
subject: Character based Search
It's not a secret anymore!