Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-30-2008, 08:39 PM
Member
 
Join Date: Apr 2008
Posts: 11
kwesiaryee is on a distinguished road
database with mysql using the netbeans 6.0
How can I create an actionlistener to insert, update and delete new data into mysql database using jbutton.

Please help me, I am comfused

Kwesi
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-01-2008, 11:37 PM
Member
 
Join Date: May 2008
Posts: 6
lonelyShoes is on a distinguished road
The logic behind this is as follows:
1) The class you add the JButton to should implement ActionListener. For example:
Code:
public class MyPanel extends JPanel implements ActionListener
2) When you create the JButton, you must add an ActionListener to it. You do this like so:
Code:
myButton.addActionListener(this);
3)In your actionPerformed method, check to see if the ActionEvent was generated by the JButton:
Code:
public void actionPerformed(ActionEvent ae){ if (ae.getSource().equals(myButton){ //......your code here.....
That is how you create a JButton, and get the ActionEvent data from it. What you would need to do in your particular case is create JButtons for Insert, Update, and Delete, and then implement the JDBC code for each situation inside your actionPerformed method. That handles the Swing side of the equation. Is that where you had difficulty, or is the JDBC code giving you problems?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-02-2008, 06:27 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,376
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
May be he looking for different action listeners for three button events. It's not much difficult too. In the 2[sup]nd[/sup] post, you have the solution.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Database and Java shaggymac Advanced Java 1 05-01-2008 11:01 PM
problem in connecting to mysql database nancyv Java Servlet 6 04-02-2008 01:33 PM
Help needed with updating mysql database SilentCodingOne New To Java 1 12-12-2007 12:23 AM
connecting to mysql database javagal NetBeans 2 08-04-2007 02:36 PM
MySql in NetBeans 5.0 javagal NetBeans 6 07-04-2007 04:34 PM


All times are GMT +3. The time now is 06:23 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org