aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes getting result in textfield using jlist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "getting result in textfield using jlist" Watch "getting result in textfield using jlist" New topic
Author

getting result in textfield using jlist

Nijin puthiya purayil
Ranch Hand

Joined: Nov 09, 2011
Posts: 32
hai friends,

i'm trying to use a jtextfiled with a jlist.....here i'm getting the values from a database to the jlist and whenever i type the name
i want, i'm getting the result in the jlist...but i can't use the arrowkeys to select these values to jtextfield...i'm able to do it with mouse
so i have to get the values in the jlist to the textfield using the arrowkeys..or enter key using the arrowkeys to traverse through the jlist
i hope you guys can help me....if my query is not clear please reply...please do help..
nijin--
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1089
    
  10

Your query is not completely clear. Let me try:
So, you are able to select an item in a List, by clicking on the list with mouse. And you are asking how to do it with arrow keys.
You need to first 'tab-in' to the component by using the tab key. A border will appear around the item in the list - a dotted border without anything selected. Then you can use the down arrow/up arrow to move through the list which will select the item.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Nijin puthiya purayil
Ranch Hand

Joined: Nov 09, 2011
Posts: 32
i think you are not clear....actually the list here i'm used is associated with a textfield...this list will appear only if i type a name or something in the textfield...
the list will display the whole matching names of the word or name i entered..it is like the dropdown list....the name i typed will only be displayed.......
here is the code i used to do so...here i think there is some problem with keyrealsed event and the list actionlistener...if you can solve this it will be very help full...thanks
tf is the jtextfield, list is the jlist, sp is the scrollpane dates represents the arralist of names from database, dlm is the defaultlistmodel
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1089
    
  10

Nijin puthiya purayil wrote:i think you are not clear....

oh ok...so, you post a question which is hard to understand, and you don't provide any code and when I point out that your query is not clear, you turn it back on me. fine.
Nijin puthiya purayil wrote:here i think there is some problem with keyrealsed event and the list actionlistener...

It is not possible for any of us to know what that 'some problem' is. Unless you explain the problem and post a SSCCE, its hard for us to help you.
Nijin puthiya purayil
Ranch Hand

Joined: Nov 09, 2011
Posts: 32
i'm sorry dude i don't meant to turn it back on you...i thought you are confused with my question...
if you are familiar with a drop down list program, can you post it for me???because i'm working on a project in which i want details of employees ..actually when i'm typing the name of a person i'm getting the desired
list as a dropdown list in that textfield...
i'm able to do further things....the only problem is that i can't select the name using my arrowkeys...
actually i posted a small part of my code here since it is a big thing...i'm a beginner in java so i'm little bit confused...
if you are still not able to help me, i will post the SSCCE here...i hope you get me thanks for your suggestion
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

Nijin puthiya purayil wrote:if you are still not able to help me, i will post the SSCCE here...

Why don't you start by doing that?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> this list will appear only if i type a name or something in the textfield...
> the list will display the whole matching names of the word or name i entered..

google
JTextField autocomplete

there's 100's (1000's?) of examples out there

if the problem is just getting the selection to the textfield (after navigating via arrow keys),
have a look at the various listeners for JList
Nijin puthiya purayil
Ranch Hand

Joined: Nov 09, 2011
Posts: 32

finally i got the result...some times google cannot give us everything,,we have to work....
..thank you all for your valuable informations
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting result in textfield using jlist