0

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();
			}
		}
2
Contributors
5
Replies
8
Views
7 Years
Discussion Span
Last Post by moutanna
0

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.");

Edited by mike_2000_17: Fixed formatting

1

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?

0

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?

Edited by ku95: n/a

1

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.