Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Extract current text from JavaTextField

Reply
Thread Tools

Extract current text from JavaTextField

 
 
stevenruiz@gmail.com
Guest
Posts: n/a
 
      05-05-2008
Hello All,

I have a question regarding the JTextField. I have the below code
which is initiated when the user clicks on a start button from the
interface:

private JButton getStartButton() {
if (startButton == null) {
startButton = new JButton();
startButton.setBounds(new Rectangle(283, 66, 71, 22));
startButton.setText("Start");
startButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
sStartPushed = true;

System.out.println(jTextField.getText());
System.out.println("actionPerformed()"); // TODO Auto-generated
Event stub
}
});
}
return startButton;
}

Inside of the action listener for this button, it prints out the text
for the textField associated with the button. Unfortunately, the text
it returns is not the current text that was just typed inside of it.
How do I get the current text? I have also tried
jTextField.getSelectedText() which does not get the current value
inside of the textField. Any comments or suggestions would be
appreciated.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
using the current method name within current method Matthew Heidemann Ruby 14 03-22-2011 03:56 AM
Please help me how is easiest way to extract text between some variable text Mladen Perl Misc 5 02-22-2011 10:57 AM
How do i extract vidios when winrar wont extract them??? help plzzzzzzzz smuttdog@sc.rr.com Computer Support 2 12-23-2007 07:03 AM
Thread.current.parent and Thread.current.ancestors ara.t.howard@noaa.gov Ruby 3 02-16-2007 03:34 PM
How to change the current thread current culture at run time. Manu ASP .Net 1 07-20-2003 03:27 PM



Advertisments