Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jerry Goldsmith
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic