Here I have a program and I'm getting the following error

ControlPanel is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
public class ControlPanel extends JPanel implements ActionListener
^

I don't fully seem to understand how the best way is to overcome this?

import java.awt.*;
import javax.swing.*;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;


public class ControlPanel extends JPanel implements ActionListener
	{

		ControlPanel model;
		Connect4Model m;

		int newCol;
		int newRow;

		JButton resetButton;
		JRadioButton twoPlayerButton;
		JRadioButton autoRedButton;
		JRadioButton autoYellowButton;
		JTextField numRows;
		JTextField numCols;


		public ControlPanel()
		{

			resetButton = new JButton("Reset Board");
			add(resetButton);
			resetButton.addActionListener(this);

			twoPlayerButton = new JRadioButton("Two Player Game");
			twoPlayerButton.addActionListener(this);
			add(twoPlayerButton);
			twoPlayerButton.setSelected(true);

			autoRedButton = new JRadioButton("Red Button");
			autoRedButton.addActionListener(this);
			add(autoRedButton);

			autoYellowButton = new JRadioButton("Yellow Button");
			autoYellowButton.addActionListener(this);
			add(autoYellowButton);

			ButtonGroup group = new ButtonGroup();
			group.add(twoPlayerButton);

			ButtonGroup group2 = new ButtonGroup();
			group.add(autoRedButton);

			ButtonGroup group3 = new ButtonGroup();
			group.add(autoYellowButton);

			numRows = new JTextField(4);
			add(numRows);
			numRows.addActionListener(this);
			numRows.setText("9");
			newCol = Integer.parseInt(numRows.getText());


			numCols = new JTextField(4);
			add(numCols);
			numCols.addActionListener(this);
			numCols.setText("7");
			newRow = Integer.parseInt(numCols.getText());

		//	model.reset(newCol, newRow);
		//	canvas.repaint();
			}
		}

Recommended Answers

All 5 Replies

Try to implement an actionPerformed in that class!
Hopr it helps.

Try to implement an actionPerformed in that class!
Hopr it helps.

I implemented the following

 public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");

you should put in the body of the function what should be done when the action is performed. Do you realy wnte to throw UnsupportedOperationException?

you should put in the body of the function what should be done when the action is performed. Do you realy wnte to throw UnsupportedOperationException?

That's good statement you put forward. However I don't see how I can implement such as fucntion?

As you did but put the code you want to be executed when the action is performed! please take a look to the javaDoc's actionPerformed before going on with this thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.