This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes JTextField problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextField problem" Watch "JTextField problem" New topic
Author

JTextField problem

Don Bosco
Ranch Hand

Joined: Oct 31, 2002
Posts: 108
Hi,
In my swing interface I have a jtextfield where user can give his input. how do i do this?
i tried setEditable(true). but it is not working. i'm executing this on solaris. is it necessary to add a listener to jtextfield for getting input from user?
any help on this?


SCJP 1.4<p>Wingardium Leviosa!!
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Need more information. What isn't working? The user can't type in the field? You can't get the informatin out?
Mandar Puranik
Ranch Hand

Joined: Jan 08, 2003
Posts: 35
Hi Don,
You will have to add an actionListener to an button, say "OK" button.
And on its clicked event, you will have to do a .getText method for that textfield.
You can refer my post "How to validate text field". I had a problem of validating the input in the textfield. It isnt solved still.
But in that post you will get the corresponding code, which I think might help you.
Let us know how it goes.
Thanks
Mandar


To Bug is Human,<br />To Debug Divine... :-))
Don Bosco
Ranch Hand

Joined: Oct 31, 2002
Posts: 108
Hi Paul,
the problem is - user cannot type in the textfield. i used setEditable(true). but still i cannot see the cursor in the textfield.

Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Post your code. There has to be something simple causing this. You aren't putting it on a disabled component are you?
Don Bosco
Ranch Hand

Joined: Oct 31, 2002
Posts: 108
Paul,
you are right. I was using these two lines for my JFrame.
setFocusCycleRoot(false);
setFocusableWindowState(false);
Got it now. Thanks Dude.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
I thought it had to be something like that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextField problem