Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Event Handling

 
leliel
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope it helps

sure. thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic