textfieldhandler is not abstract

I keep on getting the following error when I compile my code...this is my first GUI so I am sure it is something stupid

ERROR: textfieldhandler is not abstract and does not override abstract method actioPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListner

My Code:

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

publicclass Sodukoextends JFrame{

private JTextField textField[][];

private JPanel sodukoBanner, sodukoBoard, sodukoControl;

private JLabel textFieldTop;

private JButton buttonSubmit, buttonClear;

public Soduko()

{

super("Soduko" );

//Creating Pannels******************************************

sodukoBanner =new JPanel();

sodukoBanner.setLayout(new FlowLayout());

sodukoBoard =new JPanel();

sodukoBoard.setLayout(new GridLayout(9,9));

sodukoControl =new JPanel();

sodukoControl.setLayout(new FlowLayout());

//**********************************************************

//Creating top Pannel***************************************

Icon banner =new ImageIcon("Sod.gif" );

textFieldTop =new JLabel(banner);

sodukoBanner.add(textFieldTop);

//**********************************************************

//Creating all the required text fields to make the board

JTextField textField[][];

textField =new JTextField [9][9];

for(int counter1 = 0; counter1 < 9; ++counter1)

for(int counter2 = 0; counter2 < 9; ++counter2)

{

textField[counter1][counter2] =new JTextField( 1 );

//creating color scheme

if((counter1==0||counter1==1||counter1==2||counter1==6||counter1==7||counter1==8)&&

(counter2==0||counter2==1||counter2==2||counter2==6||counter2==7||counter2==8))

textField[counter1][counter2].setBackground(Color.lightGray);

elseif((counter1==3||counter1==4||counter1==5)&&(counter2==3||counter2==4||counter2==5))

textField[counter1][counter2].setBackground(Color.lightGray);

else

textField[counter1][counter2].setBackground(Color.WHITE);

//Creating the format for inside the buttons

textField[counter1][counter2].setFont(new Font("TimesRoman", Font.BOLD, 26 ) );

textField[counter1][counter2].setHorizontalAlignment(textField[counter1][counter2].CENTER);

//adding each textField to the pannel;

sodukoBoard.add( textField[counter1][counter2] );

}

//**********************************************************

//Creating Contol Pannel************************************

buttonSubmit =new JButton("Check results");

sodukoControl.add(buttonSubmit);

buttonClear =new JButton("Clear Board");

sodukoControl.add(buttonClear);

//**********************************************************

//Creating Container****************************************

Container container = getContentPane();

container.add(sodukoBanner, BorderLayout.NORTH);

container.add(sodukoBoard, BorderLayout.CENTER);

container.add(sodukoControl, BorderLayout.SOUTH);

//**********************************************************

//Registering the event handlers****************************

TextFieldHandler handler[][];

handler =new TextFieldHandler[9][9];

//= new TextFieldHandler();

for(int counter1 = 0; counter1 < 9; ++counter1)

for(int counter2 = 0; counter2 < 9; ++counter2)

{

textField[counter1][counter2].addActionListener(handler[counter1][counter2]);

}

//**********************************************************

setSize( 400, 450 );

setVisible(true );

}// end constructor Soduko

publicstaticvoid main( String args[] )

{

Soduko application =new Soduko();

application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

}

// private inner class for event handling

privateclass TextFieldHandlerimplements ActionListener{

// process textfield events

publicvoid actionPerformed( ActionEvent event[][] )

{

if(event[0][0].getSource() == textField[0][0])

{

System.out.println("test");

}

}// end method actionPerformed

}// end private inner class TextFieldHandler

Thanks for your help

[7201 byte] By [CulRock25a] at [2007-10-2 20:34:52]
# 1

The private class TextFieldHandler is declared to implement the ActionListener interface. That means it must implement a method with this signaturepublic void actionPerformed( ActionEvent event)

Your code does not have a method with that signature - you have ActionEvent[][]. You will need to modify your code so the method has the correct signature.

atmguya at 2007-7-13 23:18:03 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2

Atmguy, I changed my code to the following. But now I get a java.lang.NullPointerException. Can you help? Thank you

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Soduko extends JFrame {

private JTextField textField[][];

private JPanel sodukoBanner, sodukoBoard, sodukoControl;

private JLabel textFieldTop;

private JButton buttonSubmit, buttonClear;

public Soduko()

{

super( "Soduko" );

//Creating Pannels******************************************

sodukoBanner = new JPanel();

sodukoBanner.setLayout(new FlowLayout());

sodukoBoard = new JPanel();

sodukoBoard.setLayout( new GridLayout(9,9));

sodukoControl = new JPanel();

sodukoControl.setLayout( new FlowLayout());

//**********************************************************

//Creating top Pannel***************************************

Icon banner = new ImageIcon( "Sod.gif" );

textFieldTop = new JLabel(banner);

sodukoBanner.add(textFieldTop);

//**********************************************************

//Creating all the required text fields to make the board

JTextField textField[][];

textField = new JTextField [9][9];

for(int counter1 = 0; counter1 < 9; ++counter1)

for(int counter2 = 0; counter2 < 9; ++counter2)

{

textField[counter1][counter2] = new JTextField( 1 );

//creating color scheme

if((counter1==0||counter1==1||counter1==2||counter1==6||counter1==7||counter1==8)&&

(counter2==0||counter2==1||counter2==2||counter2==6||counter2==7||counter2==8))

textField[counter1][counter2].setBackground(Color.lightGray);

else if((counter1==3||counter1==4||counter1==5)&&(counter2==3||counter2==4||counter2==5))

textField[counter1][counter2].setBackground(Color.lightGray);

else

textField[counter1][counter2].setBackground(Color.WHITE);

//Creating the format for inside the buttons

textField[counter1][counter2].setFont( new Font( "TimesRoman", Font.BOLD, 26 ) );

textField[counter1][counter2].setHorizontalAlignment(textField[counter1][counter2].CENTER);

//adding each textField to the pannel;

sodukoBoard.add( textField[counter1][counter2] );

}

//**********************************************************

//Creating Contol Pannel************************************

buttonSubmit = new JButton("Check results");

sodukoControl.add(buttonSubmit);

buttonClear = new JButton("Clear Board");

sodukoControl.add(buttonClear);

//**********************************************************

//Creating Container****************************************

Container container = getContentPane();

container.add(sodukoBanner, BorderLayout.NORTH);

container.add(sodukoBoard, BorderLayout.CENTER);

container.add(sodukoControl, BorderLayout.SOUTH);

//**********************************************************

//Registering the event handlers****************************

TextFieldHandler handler= new TextFieldHandler();

for(int counter1 = 0; counter1 < 9; ++counter1)

for(int counter2 = 0; counter2 < 9; ++counter2)

{

textField[counter1][counter2].addActionListener(handler);

}

//**********************************************************

setSize( 400, 450 );

setVisible( true );

} // end constructor Soduko

public static void main( String args[] )

{

Soduko application = new Soduko();

application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

}

// private inner class for event handling

private class TextFieldHandler implements ActionListener {

// process textfield events

public void actionPerformed( ActionEvent event)

{

if(event.getSource() == textField[0][0])

{

System.out.println("test");

}

} // end method actionPerformed

} // end private inner class TextFieldHandler

CulRock25a at 2007-7-13 23:18:03 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3
remove this lineJTextField textField[][];You are re-declaring textField, which hides the instance variable.
atmguya at 2007-7-13 23:18:03 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4
Thank you so much. It works!
CulRock25a at 2007-7-13 23:18:03 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...