This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Event Handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Event Handling" Watch "Event Handling" New topic
Author

Event Handling

leliel
Greenhorn

Joined: Mar 25, 2003
Posts: 11
Hi,
I wrote 2 classes:
mainframe.java and submitactionlistener.java.
The mainframe class implements a frame and contains some swing components, including a submit button.
If the button is clicked, a method should run, getting values from a JComboBox and a JTextField and save this stuff in the database.
But I don't know how to handle this.
The ActionListener works fine, but I couldn't find a way reading out the values and safe them ...
any help?
Younes Essouabni
Ranch Hand

Joined: Jan 13, 2002
Posts: 479
Maybe, you may try declaring your components as private static. And implementing some getter and setter.
e.g:

This way, you may get and set your JTextField whenever you want in your SubmitActionListener, simply like this

I hope it was what you wanted


Younes
By constantly trying one ends up succeeding. Thus: the more one fails the more one has a chance to succeed.
Younes Essouabni
Ranch Hand

Joined: Jan 13, 2002
Posts: 479
Oups, sorry, I didn't see that you wanted to save it in a database. For this, you should open a connection to your database.
Create a query with the values that you retrieved from the JTextField and then execute the query.
For that you should make a quick search in the jdbc forum
I hope it helps
leliel
Greenhorn

Joined: Mar 25, 2003
Posts: 11
I hope it helps

sure. thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Event Handling
 
Similar Threads
validating the arraylist values in struts
Values from ListBox to be inserted
get value from radio button
validating the arraylist values in struts
Adding of new user is sucessfull and present in the datebase but not showing in the list