Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

..is not abstract and does not override abstract method..

807589Jul 23 2008 — edited Jul 26 2008
Hello,
I've been creating a GUI from scratch, up to now, i have managed to successfully compile the code which forms the window, and a JMenu bar. I now need to add buttons, and for this i need to use an ActionListener, but when i put "implements ActionListener" at the end of "public class TestCode extends JFrame", i recieve the above error message (abstract..). I've looked at recent posts and have come across a post that says adding "actionPerformed(java.awt.event.ActionEvent e)" to the class will resolve the issue. When i add that, i recieve a compile error message saying to add '{' after actionPerformed. I've done this however it still does not compile. Can anyone point me in the right direction please?

Thanks
George
import java.awt.*;
import java.awt.event.*;
import javax.swing.JMenu;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JButton;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.ImageIcon;
import javax.swing.AbstractButton;
import javax.swing.JFrame;
import java.awt.event.KeyEvent;

import java.util.*;

	
public class TestCode extends JFrame  {


    private static void createAndShowGUI() {
	
	    
	JFrame.setDefaultLookAndFeelDecorated(true);
      

        JFrame frame = new JFrame("Robot Control Station");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	
	JMenuBar menuBar = new JMenuBar();
	
	JMenu fileMenu = new JMenu("Exit");
	fileMenu.setMnemonic(KeyEvent.VK_F);
	menuBar.add(fileMenu);
	
        JLabel emptyLabel = new JLabel("");
        emptyLabel.setPreferredSize(new Dimension(750, 750));
        frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
	
	JMenuItem newMenuItem = new JMenuItem("Exit Program", KeyEvent.VK_N);
	fileMenu.add(newMenuItem);
	

	frame.setJMenuBar(menuBar);
	frame.setVisible(true);
	
        //Display the window.
        frame.pack();
        frame.setVisible(true);

       //forward button
	
	JButton forward = new JButton("Forward");
	forward.setMnemonic(KeyEvent.VK_D);
        forward.setActionCommand("disable");
	forward.setToolTipText("Click this button to make the robot go forward.");
	forward.add(forward);
	frame.setVisible(true);
	
	
	
    }
    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}

	
	 
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2008
Added on Jul 23 2008
18 comments
820 views