• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

setDefaultClosingOperation  RSS feed

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a very simple application that I have a problem with the basi code is
package really.trying;
import javax.swing.*;

public class swingStuff() {
public swingStuff() {
JFrame frame = new JFrame("Tester");
JButton but1 = new JButton("Test");
frame.getContentPane().add(but1);
frame.setVisible(true);
frame.setSize(300,300);
frame.setDefaultClosingOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
swingStuff new1 = new swingStuff();
}
}
I know its very very basic, I don't even have a Layout Manager but I wanted to start very simple. Any advice or help will be very appreciated.
 
author and iconoclast
Sheriff
Posts: 24220
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

It's "setDefaultCloseOperation". Use the Javadocs to look these things up.

It's a good idea to call setVisible() last, after everything else about a window is already set up.
 
Jesse Walker
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I just looked right over that. Appreciate it
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!