Java窗体Hello World

打算玩玩手机开发(Android)先回忆一下Java语法。
用Java开发Windows程序意义不大,简单熟悉一下。
重要是Android开发,搞一个手机围棋玩玩,现在好用的手机围棋不多。
会围棋的不懂编程,懂编程的不会围棋,这是个问题,本人围棋比编程水平高,呵呵。
有同好的朋友,请留言一起玩玩手机围棋。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public  class Hello {

     /**
     * 
@param  args
     
*/
     public  static  void main(String[] args) {
         //  TODO Auto-generated method stub
        System.out.println("hello");
        PlafFrame frame =  new PlafFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible( true);
    }

}
//  A Frae with a button panel for chaing look and fell
class PlafFrame  extends JFrame {

     public  static  final  int DEFAULT_WIDTH = 300;
     public  static  final  int DEFAULT_HEITHT = 200;

     public PlafFrame() {

        setTitle("PlaF Test");
        setBounds(350, 250, DEFAULT_WIDTH, DEFAULT_HEITHT);
        PlafPanel panel =  new PlafPanel();
        add(panel);
    }

}

//  A panel with buttons to change the pluggable look and fell
class PlafPanel  extends JPanel {
     public PlafPanel() {
        UIManager.LookAndFeelInfo[] infos = UIManager
                .getInstalledLookAndFeels();
         for (UIManager.LookAndFeelInfo info : infos)
            makeButton(info.getName(), info.getClassName());

    }

     void makeButton(String name,  final String plafName) {

         //  add button to panel

        JButton button =  new JButton(name);
        add(button);

         //  set button action

        button.addActionListener( new ActionListener() {
             public  void actionPerformed(ActionEvent event) {

                 //  button action :switch to the new look and feel
                 try {
                    UIManager.setLookAndFeel(plafName);
                    SwingUtilities.updateComponentTreeUI(PlafPanel. this);

                }  catch (Exception e) {
                    e.printStackTrace();
                }

            }

        });
    }

}
url: http://greatverve.cnblogs.com/archive/2011/12/29/java-window-hello-world.html#
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值