用Swing写的简易Hello World

来源:互联网 发布:java成绩管理系统简单 编辑:程序博客网 时间:2024/05/18 01:49
package JavaPractice;import javax.swing.*;public class HelloWorldSwing{public void HelloWorldJFrame(){JFrame hws = new JFrame("Hello World Swing");JLabel hw = new JLabel("Hello World!");hws.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);hws.setVisible(true);hws.setSize(320, 240);hws.getContentPane().add(hw);hw.setHorizontalAlignment(SwingConstants.CENTER);}public static void main(String args[]){new HelloWorldSwing().HelloWorldJFrame();}}