GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Calling a button to perform add function into database. Please help with the code. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Calling a button to perform add function into database. Please help with the code. " Watch "Calling a button to perform add function into database. Please help with the code. " New topic
Author

Calling a button to perform add function into database. Please help with the code.

Yuta Lolap
Ranch Hand

Joined: Jun 03, 2012
Posts: 83

I have created a button on my Dashboard.java file as follows and i have a added a actionlistener to it and written the fuction in the a different class. What is want is when i click on the button add i want the items to be added in to the database.
Am i calling the add button e.getsource()the right way or is it wrong?
------------------------------------------------
Dashboard.java partial code

----------------------------------------------------

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Please UseCodeTags (<- click this link) the next time you want to post some code.
I have added them for you this time.


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Am i calling the add button e.getsource()the right way or is it wrong?

Yes, this is one way to do it.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39079
    
  23
I don’t like any action listeners with getSource in. But you have bigger problems than that, if you are not adding in the database.
I think you are going about the whole exercise the wrong way. Start by working out what to do in the database. Then work out a query, and get it working from the command line with a Java application. Once you have got that working, you can put the GUI on top of that. I think you will find your application quicker and easier to build like that.
Yuta Lolap
Ranch Hand

Joined: Jun 03, 2012
Posts: 83

thanks i got it solved!
 
GeeCON Prague 2014
 
subject: Calling a button to perform add function into database. Please help with the code.