aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark ""...not abstract and does not override abstract method..."" Watch ""...not abstract and does not override abstract method..."" New topic
Author

"...not abstract and does not override abstract method..."

Jerry Goldsmith
Ranch Hand

Joined: Nov 29, 2006
Posts: 53
Thanks for all the help from the experienced Java folks that I have received on this forum so far. I am still working on getting a text string from the user into my code. Since I am using J-Link with Pro/Engineer CAD software I cannot use "JOptionPane.showInputDialog" or similar because the window always shows up behind my main application window.

As a result I am forced to build my own dialog from scratch. This successfully displays the dialog window; but, the text from the text field is not successfully read into the string variable. In order to alleviate this problem I am attempting to implement an ActionListener.

At compile time, I receive the error message: "Jerry_Test is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener"

Any help would be greatly appreciated. Here is my code:

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

public class Jerry_Test implements ActionListener
{

public static void start()
{

JFrame parentFrame = new JFrame();
JLabel new_label = new JLabel("New part number");
final JTextField new_text = new JTextField(50);
JPanel new_panel = new JPanel();
new_label.setLabelFor(new_text);
new_panel.add(new_label);

JOptionPane new_pane = new JOptionPane(new_panel);
new_pane.setWantsInput(true);

JDialog new_dialog = new_pane.createDialog(parentFrame, "Test dialog");
new_dialog.setModal(false);
new_dialog.setVisible(true);
new_dialog.toFront();

new_text.addActionListener
(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String new_name = new_text.getText();
}
}
);

}

public static void stop()
{
}

}
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

As the error message says, Jerry_Test declares that it "implements ActionListener", but it does not; the class JerryTest doesn't implement the method "actionPerformed" declared in that interface.

Since you're using an anonymous class as your actual listener, Jerry_Test doesn't need to implement this interface for any reason, anyway, so just remove those two words "implements ActionListener" and you'll be good.

Do you have an intro Java programming text? Java isn't a scripting language where you can copy a line from here and a line from there; it really, really helps to have some understanding of what you're writing.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "...not abstract and does not override abstract method..."