This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How to set the size of the default window in swing  RSS feed

Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I nevwe worked with swing and i am trying to do a sample application. can any one please tell me how to set the size of the default window that shows up where i have all my component

My constructor looks like below
public WordXMLMain(){
super(new BorderLayout());

// Label initilization
lblFileName = new JLabel();
// Text Area initilization
txtOutput = new JTextArea(5,20);
txtOutput.setMargin(new Insets(10,10,10,10));
txtOutput.setSize(250, 500);
JScrollPane outputScrollPane = new JScrollPane(txtOutput);

fc = new JFileChooser();
// Button Initilization
btnOpenFile = new JButton("Choose File");

btnProcessFile = new JButton("Process File");

JPanel panel = new JPanel();


JPanel panel1 = new JPanel();

add(panel, BorderLayout.BEFORE_FIRST_LINE);

add(outputScrollPane, BorderLayout.CENTER);
add(panel1, BorderLayout.SOUTH);


Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After adding and sizing all of the components, try this:

The call to "pack()" lets the layout manager size and position each component for display, and then sets the default size of the container so each component is visible (if there is enough room on the screen).
[ December 19, 2003: Message edited by: Wayne L Johnson ]
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me:
how do I do my own kindle-like thing - without amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!