943,363 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 7382
  • Java RSS
Jul 25th, 2003
0

JTextField

Expand Post »
Hi..I've been searching all around to find out whether I could submit an entry in a JTextField by clicking a separate button created (say, a "submit" button).
It seems that, the value entered in the text field will only be appended if I press the Enter key. Can someone please help? Thx!
Reputation Points: 53
Solved Threads: 1
Posting Whiz
red_evolve is offline Offline
313 posts
since Jun 2003
Jul 28th, 2003
0

Re: JTextField

A combination of events can be used for the same listener; listening to i.e. when a certain key is pressed by adding a KeyAdapter's KeyEvent, and listening to when a certain button is being pressed by using the ActionListener's ActionEvent.

So if i.e. a "ok" button should do something one could write a listener class that do the following:

Java Syntax (Toggle Plain Text)
  1. Class OkListener extends KeyAdapter implements ActionListener {
  2.  
  3. public void keyTyped(KeyEvent ke) {
  4. // Code for what happens to the JTextField when a certain key is be pressed...
  5. }
  6.  
  7. public void actionPerformed(ActionEvent ae) {
  8. // Code for what happens to the JTextField when a button is clicked on...
  9. }
  10.  
  11. }


Hope this is of some help,
/Soo-Im
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sooim3 is offline Offline
11 posts
since Jun 2003
Jul 28th, 2003
0

Re: JTextField

Hehe... I've got it already...because my assignment duedate was yesterday. It's actually a very simple way of solving...But thank you anyway...
Reputation Points: 53
Solved Threads: 1
Posting Whiz
red_evolve is offline Offline
313 posts
since Jun 2003

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Writing to an Access Database using Java...
Next Thread in Java Forum Timeline: java 3d viewable to everyone





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC