This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Application runs and closes automatically 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 "Application runs and closes automatically" Watch "Application runs and closes automatically" New topic
Author

Application runs and closes automatically

Abder-Rahman Ali
Ranch Hand

Joined: May 22, 2008
Posts: 138
I have this code which is a JFrame with a JPanel and three buttons.

When I run the program it just closes AUTOMATICALLY. Why is that?



Thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

What you think is a constructor isn't. It's a method that has the same name as a constructor would. Instead you are calling the default constructor that is generated automatically. Remove the "void" and see what happens.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Abder-Rahman Ali
Ranch Hand

Joined: May 22, 2008
Posts: 138
Thanks Rob, you are absolutely right.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Application runs and closes automatically
 
Similar Threads
Problems Resizing TextArea
Problems using JTabbedPane In a GUI application
GUI interaction
Press a button and draw a shape
Java Programming Help (conversions)