to-do for 'MyHelloSwing'

import javax.swing.*;
/*public class MyHelloSwing{
 public static void main(String [] args){
 JFrame f = new JFrame("HelloWorldSwing!");
 JLabel l = new JLabel("Hello World,it's mine!!!");
 //f.getContentPane().addLabel(l);
 f.getContentPane().add(l);
 f.pack();
 f.setVisible(true);
 }
}*/
public class MyHelloSwing {
 /*private class creatGUI() {
  //make nice
  JFrame.setDefaultLOOKANDFEEL(true);
  
  //creat and set up the top-level container.
  JFrame f = new JFrame("Wang's helloSwing!");
  f.setDefaultCloseOnFrame(EXIT_ON_CLOSE);
  f.position(10,10);//想确定JFrame的位置
  
  //creat JLabel
  JLabel l = new JLabel("hello world,it't mine!!!!");
  f.getContentPane().add(l);
  
  f.pack();
  f.setVisible();
 }*/
 private static void createAndShowGUI() {
        //Make sure we have nice window decorations.
        JFrame.setDefaultLookAndFeelDecorated(true);

        //Create and set up the window.
        JFrame frame = new JFrame("HelloWorldSwing");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocation(250, 300);
        //frame.position(10,10);//想确定JFrame的位置,不成功,自己瞎猜了个方法,嘿嘿,:)

        //Add the ubiquitous "Hello World" label.
        JLabel label = new JLabel("Hello World");
        frame.getContentPane().add(label);

        //Display the window.
        frame.setSize(350,200);//怎么不管事呀???
        //frame.pack();
        frame.setVisible(true);
    }
 public static void main(String [] args){//下面的这个我可是一点也没能题解呀……
  //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
       javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}

1,细看,分析,练习 javax.swing.SwingUtilities.invokeLater(new Runnable() 

2,frame.setSize()与frame.pack()有冲突????

3,setDefaultLookAndFeelDecorated(true);从哪些方面考虑放在第一行呢???

4,setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);这个长变量,记住,没啥说的。

  
 

你可能感兴趣的:(to-do for 'MyHelloSwing')