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()
{
}
}
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()
{
}
}