Urgent!ActionListener not working...
i have a assign due next monday and i was wondering if anyone could help me with my action listener i don't understand why my action listener is not working
here are the example of codes for my action listener:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
class buttonPanel extends Panel implements ActionListener{
private static final int BUTTON_WIDTH = 80;
private static final int BUTTON_HEIGHT = 30;
private Button saveButton,resetButton,cancelButton;
private TextField tf0,tf1,tf2,tf3,tf4,tf5,tf6,tf7,tf8,tf9;
public buttonPanel () {
saveButton = new Button("SAVE");
saveButton.setBounds(380,20, BUTTON_WIDTH, BUTTON_HEIGHT);
saveButton.addActionListener(this);
add(saveButton);
resetButton = new Button("RESET");
resetButton.setBounds(480,20, BUTTON_WIDTH, BUTTON_HEIGHT);
resetButton.addActionListener(this);
add(resetButton);
cancelButton = new Button("CANCEL");
cancelButton.setBounds(580,20, BUTTON_WIDTH, BUTTON_HEIGHT);
cancelButton.addActionListener(this);
add(cancelButton);
}
//The implementation of ActionListener
public void actionPerformed (ActionEvent e){
if(e.getActionCommand().equals("saveButton")){
Jdbc j = new Jdbc();
j.Open("PP", "", "");
j.Update("insert into HarvestFile (TreeID, SegmentCode, DateOfHarvest, NumberOfTrees, ForestOfficer)" +
"values" + tf0.getText() + "','" + tf1.getText() + "','" + tf2.getText() + "','" +
tf3.getText() + "','" + tf4.getText() + "');");
j.Clear();
j.Close();
}
else if(e.getActionCommand().equals("cancelButton")){
HRecordFrame harvest = MainFrame.HRecord;
harvest.show();
HRecordPanel.haf.dispose();
}
else {
tf0.setText("");
tf1.setText("");
tf2.setText("");
tf3.setText("");
tf4.setText("");
tf5.setText("");
tf6.setText("");
tf7.setText("");
tf8.setText("");
tf9.setText("");
}
}
}
Thanks is advance!
harvin

