1>import java.awt.*;
2>import java.awt.event.*;
3>import javax.swing.*;
4>
5>
6>public class FrameDemo {
7>
8> private static void createAndShowGUI() {
9>
10> JFrame frame = new JFrame("FrameDemo");
11> frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
12>
13> JLabel emptyLabel = new JLabel("Prasanna");
14> emptyLabel.setPreferredSize(new Dimension(1000, 1000));
15> frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
16>
17>
18> frame.pack();
19> frame.setVisible(true);
20> }
21>
22> public static void main(
String[] args) {
23> javax.swing.SwingUtilities.invokeLater(new Runnable() {
24> public void run() {
25> createAndShowGUI();
26> }
27> });
28> }
29>}
/************ doubts*******************/
FIRST DOUBT : on line 11 even if i skip that line the frame exits on pressing x then whats the use?
SECOND DOUBT : on line 14 the dimensions are set for Jlabel ie the string "Prasanna" should be Displayed larger then why Jframe dimension changed??