User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 391,555 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,613 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 5245 | Replies: 2
Reply
Join Date: Jun 2003
Location: Malaysia
Posts: 313
Reputation: red_evolve is on a distinguished road 
Rep Power: 6
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

JTextField

  #1  
Jul 25th, 2003
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!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2003
Posts: 11
Reputation: sooim3 is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 0
sooim3 sooim3 is offline Offline
Newbie Poster

Re: JTextField

  #2  
Jul 28th, 2003
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:

Class OkListener extends KeyAdapter implements ActionListener {

   public void keyTyped(KeyEvent ke) {
      // Code for what happens to the JTextField when a certain key is be pressed...
   }

   public void actionPerformed(ActionEvent ae) {
      // Code for what happens to the JTextField when a button is clicked on...
   }

}


Hope this is of some help,
/Soo-Im
Reply With Quote  
Join Date: Jun 2003
Location: Malaysia
Posts: 313
Reputation: red_evolve is on a distinguished road 
Rep Power: 6
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: JTextField

  #3  
Jul 28th, 2003
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...
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 9:38 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC