Results 1 to 8 of 8
- 08-26-2010, 12:16 AM #1
Member
- Join Date
- Aug 2010
- Posts
- 7
- Rep Power
- 0
Issue with obtaining data from the JTextField when JButton is pressed
I have a JTextField (name), and a JButton (btnOK). When i type something into "name", and press enter, i can display the text using System.out.println(name);
But when select "btnOK" after writing something to "name", it won't display the contents of "name". Is there a simple explanation to this, or do you guys guys want to see some code.
Thanks in advance
- 08-26-2010, 12:23 AM #2
Did you add an action listener to the btnOK ?
-
Without code, I think that there's no way on heaven or earth we can guess what you're doing wrong. Please be sure to use code tags, and optimally you should create and post an SSCCE. Please read the link to find out what is involved with that but briefly you'd be creating a small version of your code that compiles and runs and demonstrates your error.
- 08-26-2010, 01:12 AM #4
Member
- Join Date
- Aug 2010
- Posts
- 7
- Rep Power
- 0
Yes I did. Ill post some code up in a bit
- 08-26-2010, 02:32 AM #5
Member
- Join Date
- Aug 2010
- Posts
- 7
- Rep Power
- 0
Figured it out guys. Thanks. i was trying to access the information from a different panel
- 08-26-2010, 04:37 AM #6
Member
- Join Date
- Jun 2010
- Posts
- 28
- Rep Power
- 0
A little known fact: you can add an ActionListener to a JTextField. The action performed method is called when you hit the enter key.
- 08-26-2010, 04:49 AM #7
Member
- Join Date
- Aug 2010
- Posts
- 7
- Rep Power
- 0
Yep. But that's not going to get all 6 jtextfields at once.
- 08-29-2010, 10:33 AM #8
Similar Threads
-
JButton with Icon & text alignment issue
By ShardaD in forum AWT / SwingReplies: 4Last Post: 01-11-2011, 11:10 AM -
Highlight JTextField using Jbutton?
By goffy in forum New To JavaReplies: 11Last Post: 05-02-2010, 11:41 AM -
JXL, Numeric data issue
By only2008 in forum Java ServletReplies: 0Last Post: 02-27-2009, 11:36 AM -
[SOLVED] JtextField alignments issue.......?
By prabhurangan in forum AWT / SwingReplies: 2Last Post: 06-19-2008, 08:50 AM -
how to display a sum of all previously pressed numbers in JTextField?
By all eyes in forum New To JavaReplies: 2Last Post: 03-30-2008, 08:38 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks