2 Replies - 1204 Views - Last Post: 11 March 2012 - 10:46 AM Rate Topic: -----

#1 Skatters69   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 28-February 12

class is not abstract and doesn't override abstract

Posted 11 March 2012 - 10:33 AM

I tried reading through my book/googling this error that I'm getting..

I'm getting this error message "class is not abstract and does not override abstract method actionPerformed(ActionEvent) in ActionListener.

I'm doing this program for a class assignment and I'm stumped here, I built my GUI before implementing ActionListeners and I'm lost, I'm not sure what I've done wrong and I'm debating whether to just start the whole project over again, any help is appreciated.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;


public class GolfScores extends JPanel implements ActionListener
{
	private final JFrame frame = new JFrame("Belvedere Match Play");
	private JPanel mainPanel, topPanel, middlePanel, bottomPanel;
	private int holeNumber = 1;

	public GolfScores()
	{final JFrame frame = new JFrame("Belvedere Match Play");
	frame.setBackground(Color.WHITE);

	JLabel holeNumbLabel = new JLabel("Hole #" + holeNumber);
	ImageIcon golfCourse = new ImageIcon("C:/sn0wbreeze/belvedere_image.jpg");
	JLabel golfCourseNameLabel = new JLabel("Belvedere");
	JLabel golfCourseLabel = new JLabel (golfCourse);
	golfCourseLabel.setFont (new Font("Arial", Font.BOLD, 25));

	topPanel.setPreferredSize(new Dimension(400, 400));
	topPanel.add (golfCourseNameLabel);
	topPanel.add (golfCourseLabel);
	topPanel.add (holeNumbLabel);
	topPanel.setBackground(Color.WHITE);
	topPanel.setVisible(true);

	JPanel middlePanel = new JPanel();

	JTextField player = new JTextField(2);
	JTextField cpu = new JTextField(2);
	JLabel opo = new JLabel("Opponent: ");
	JLabel plr = new JLabel("Player: ");
	int playerPoints = 0;
	JLabel playerScore = new JLabel("Player Score:" + playerPoints);

	middlePanel.setPreferredSize(new Dimension(200, 200));
	middlePanel.add(plr, BorderLayout.WEST);
	middlePanel.add(player, BorderLayout.WEST);
	middlePanel.add(opo, BorderLayout.EAST);
	middlePanel.add(cpu, BorderLayout.EAST);
	middlePanel.add(playerScore, BorderLayout.CENTER);
	middlePanel.setBackground(Color.WHITE);

	JPanel bottomPanel = new JPanel();

		JButton enterScores = new JButton("Enter Score");
		enterScores.setBackground(Color.GREEN);
		JButton matchOver = new JButton("End Match");
		matchOver.setBackground(Color.RED);

		bottomPanel.add(enterScores, BorderLayout.EAST);
		bottomPanel.add(matchOver, BorderLayout.WEST);
		bottomPanel.setBackground(Color.WHITE);

		mainPanel.setPreferredSize(new Dimension (400,800));
		mainPanel.add(topPanel);
		mainPanel.add(middlePanel,BorderLayout.CENTER);
		mainPanel.add(bottomPanel,BorderLayout.SOUTH);
		mainPanel.setVisible(true);

		frame.getContentPane().add(mainPanel);
		frame.pack();
		frame.setVisible(true);
	}
}


Is This A Good Question/Topic? 0
  • +

Replies To: class is not abstract and doesn't override abstract

#2 GregBrannon   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2250
  • View blog
  • Posts: 5,340
  • Joined: 10-September 10

Re: class is not abstract and doesn't override abstract

Posted 11 March 2012 - 10:39 AM

Classes the implement the interface ActionListener must include the method actionPerformed( ActionEvent ). It looks like:
    public void actionPerformed( ActionEvent e )
    {
        // action to perform goes here.
    }

Was This Post Helpful? 1
  • +
  • -

#3 Skatters69   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 28-February 12

Re: class is not abstract and doesn't override abstract

Posted 11 March 2012 - 10:46 AM

View PostGregBrannon, on 11 March 2012 - 10:39 AM, said:

Classes the implement the interface ActionListener must include the method actionPerformed( ActionEvent ). It looks like:
    public void actionPerformed( ActionEvent e )
    {
        // action to perform goes here.
    }


Thanks Greg.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1