Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Why doesn't my WindowListener work?

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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");
}

}
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
worked OK for me, java 1.4.0_01
 
Jerry Goldsmith
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still doesn't work for me. JDK 1.4.2.
 
Do not threaten THIS beaver! Not even with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic