import javax.swing.*;public class useJFrame {
JFrame mainFrame;
JLabel myJLabel;
public useJFrame() {
mainFrame=new JFrame("JFrame演示窗口");
myJLabel=new JLabel("世界,你好");
mainFrame.getContentPane().setLayout(new FlowLayout());//设置布局
mainFrame.getContentPane().add(myJLabel); //注意这种添加组件的方法
mainFrame.pack();
mainFrame.setVisible(true);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} public static void main(String[] args) {
new useJFrame();
}
}
JFrame mainFrame;
JLabel myJLabel;
public useJFrame() {
mainFrame=new JFrame("JFrame演示窗口");
myJLabel=new JLabel("世界,你好");
mainFrame.getContentPane().setLayout(new FlowLayout());//设置布局
mainFrame.getContentPane().add(myJLabel); //注意这种添加组件的方法
mainFrame.pack();
mainFrame.setVisible(true);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} public static void main(String[] args) {
new useJFrame();
}
}
mainFrame.add(myJLabel);
JFrame mainFrame;
JLabel myJLabel;
public useJFrame() {
mainFrame=new JFrame("JFrame演示窗口");
myJLabel=new JLabel("世界,你好");
mainFrame.getContentPane().setLayout(new FlowLayout());//设置布局
mainFrame.getContentPane().add(myJLabel); //注意这种添加组件的方法
mainFrame.pack();
mainFrame.setVisible(true);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} public static void main(String[] args) {
new useJFrame();
}
}