wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes NOT Abstract ERROR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NOT Abstract ERROR" Watch "NOT Abstract ERROR" New topic
Author

NOT Abstract ERROR

Rick Katka
Greenhorn

Joined: Feb 22, 2004
Posts: 7
Clock/JFrameTime.java [19:1] Clock.JFrameTime is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
public class JFrameTime extends javax.swing.JFrame implements ActionListener, ItemListener, Observer
^
1 error
I'm getting this error in a boundry class that the Sun One IDE generated for me to create a JFrame for a clock. I cant' seem to find this error anywhere on the web and it's really stumping me.
Hopefully someone out there has seen something like this before.
Rick Katka
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
You are actually implementing the ActionListener interface which has "action Performed(java.awt.event.ActionEvent)" declared in it.
And when we implement any interface we will have to define the methods declared in that interface otherwise we have to declare our class as abstract.
So you will have to implement that method.
Rick Katka
Greenhorn

Joined: Feb 22, 2004
Posts: 7
Here is the code :
It seems like there already is an action Performed method for the jButton1 which is the submit button. And it has an actionListener so it's confusing me right now.
//Boundry Class
/*
* JFrame.java
*
* Created on April 19, 2004, 8:03 PM
*/
package Clock;
import java.util.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
/**
*
* @author Rick Katka
*/
public class JFrameTime extends javax.swing.JFrame implements ActionListener, ItemListener, Observer
{
private MyTime myTime; //reference to mytime
private JFrameTime jfTime; //reference to jframeTime
/** Creates new form JFrame */
public JFrameTime()
{
initComponents();
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
getContentPane().setLayout(new java.awt.GridLayout(1, 0));
setTitle("Clock");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel1.setText("Hours:");
getContentPane().add(jLabel1);
jTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField1.setText("1");
getContentPane().add(jTextField1);
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel2.setText("Minutes:");
getContentPane().add(jLabel2);
jTextField2.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField2.setText("0");
getContentPane().add(jTextField2);
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel3.setText("Seconds:");
getContentPane().add(jLabel3);
jTextField3.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField3.setText("0");
getContentPane().add(jTextField3);
jButton1.setText("SUBMIT");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel4.setText("12:00:00");
getContentPane().add(jLabel4);
pack();
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// Add your handling code here:
//submit button-->triggers to setTime and possibly to beging incrementing the time
myTime.setHour(Integer.parseInt(jfTime.jTextField1.getText() ) ); //setsHour by getting whats in the textfield
myTime.setMinute(Integer.parseInt(jfTime.jTextField2.getText() ) ); //setsMinute by getting whats in the textfield
myTime.setSecond(Integer.parseInt(jfTime.jTextField3.getText() ) ); //setsSecond by getting whats in the textfield

myTime.setTime(myTime.getHour(),myTime.getMinute(),myTime.getSecond()); //sets the time officially
}

/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
public void update()
{
jLabel4.setText(myTime.getTime() );
}

// Variables declaration - do not modify
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
private javax.swing.JTextField jTextField3;
private javax.swing.JLabel jLabel2;
private javax.swing.JButton jButton1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField1;
// End of variables declaration

}
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

That actionPerformed() is in an anonymous inner class, not in the JFrameTime class. The easiest way out of this mess is just to remove the "implements ActionListener" from the class declaration.


[Jess in Action][AskingGoodQuestions]
 
Consider Paul's rocket mass heater.
 
subject: NOT Abstract ERROR