Results 1 to 3 of 3
- 04-30-2008, 06:39 PM #1
Member
- Join Date
- Apr 2008
- Posts
- 11
- Rep Power
- 0
- 05-01-2008, 09:37 PM #2
Member
- Join Date
- May 2008
- Posts
- 6
- Rep Power
- 0
The logic behind this is as follows:
1) The class you add the JButton to should implement ActionListener. For example:
2) When you create the JButton, you must add an ActionListener to it. You do this like so:Java Code:public class MyPanel extends JPanel implements ActionListener
3)In your actionPerformed method, check to see if the ActionEvent was generated by the JButton:Java Code:myButton.addActionListener(this);
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?Java Code:public void actionPerformed(ActionEvent ae){ if (ae.getSource().equals(myButton){ //......your code here.....
- 05-02-2008, 04:27 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
May be he looking for different action listeners for three button events. It's not much difficult too. In the 2nd post, you have the solution.
Similar Threads
-
MySQL Database and Java
By shaggymac in forum Advanced JavaReplies: 1Last Post: 05-01-2008, 09:01 PM -
problem in connecting to mysql database
By nancyv in forum Java ServletReplies: 6Last Post: 04-02-2008, 11:33 AM -
Help needed with updating mysql database
By SilentCodingOne in forum New To JavaReplies: 1Last Post: 12-11-2007, 10:23 PM -
connecting to mysql database
By javagal in forum NetBeansReplies: 2Last Post: 08-04-2007, 12:36 PM -
MySql in NetBeans 5.0
By javagal in forum NetBeansReplies: 6Last Post: 07-04-2007, 02:34 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks