File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Why doesn't my WindowListener work? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Why doesn Watch "Why doesn New topic
Author

Why doesn't my WindowListener work?

Jerry Goldsmith
Ranch Hand

Joined: Nov 29, 2006
Posts: 53
I am trying to execute a test method inside my window listener. All it is supposed to do is show a dialog saying "Inside listener" when the first dialog closes. I can't seem to get it to work. Can anyone see what I'm doing wrong? Thanks. Here is the code:

public class Jerry_Test
{
public static void start()
{

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

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

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

new_dialog.addWindowListener
(
new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
test_output();
}
}
);

}

public static void stop()
{
}

public static void test_output()
{
JFrame parentFrame_2 = new JFrame();
JOptionPane.showMessageDialog(parentFrame_2, "Inside the listener");
}

}
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
worked OK for me, java 1.4.0_01
Jerry Goldsmith
Ranch Hand

Joined: Nov 29, 2006
Posts: 53
Still doesn't work for me. JDK 1.4.2.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why doesn't my WindowListener work?
 
Similar Threads
OK button does not dispose of parent frame within ActionListener
"...not abstract and does not override abstract method..."
ActionListener illegal start of expression
Adding a text field to JDialog with JTextField
getText() doesn't work