hello All,
i am working on a small project to show people address through there names , for example the user will enter the name and it will show him the address of the entered name.. but the big issue here is that i want to googlize it which means when i enter in the search area "M" it show down most of the people whose name begins with "M" and if i continued "MA" it also show the names which begins with these letters "MA" something like what google does, thanks for your attention :)

Web application with JSP, or Desktop application with swing ?

desktop application

what you mean with desktop application

Entering in a JTextField? I'd probably try addint a KeyListener. When it fires a keyTyped KeyEvent, get the current text and off you go.

sorry i can't get your point

desktop application means that the software runs on a computer (ordinary software on any computer) not on a server(web site)

Have you ever added an ActionListener to one of your buttons. So whenever you click a button the actionPeformed method will be executed.

It is the same thing. Add a KeyListener to the text field.
Use the addKeyListener method of the JTextField class. You need to implement the KeyListener listener interface. You don't need to write code in all of the methods. Just write for only the keyReleased. When you enter text at the field, every time you release a key from the keyboard that method is executed. So all you have to do is take the text from the field

JTextField nameField = new JTextField();


public void keyReleased(KeyEvent e) {
   String name = nameField.getText();

   System.out.println(name);
}

If you try to enter the name: JACK, the above method will print:
> J
> JA
> JAC
> JACK

Every time you release a "key" that method is executed. So if you have a method that returns the names that begin with the argument, take the text from the field call that method and show the results. That will be executed every time you keep entering characters in the field.

The hard part is after you have the list with names how to make it look like "google". For that you need to do a little search, on the net. Because I don't have the time to do some searching and point you to right direction.

ok thanks you man i will try it then return to you back to inform you about the results

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.