Java窗体Hello World
打算玩玩手机开发(Android)先回忆一下Java语法。
用Java开发Windows程序意义不大,简单熟悉一下。
重要是Android开发,搞一个手机围棋玩玩,现在好用的手机围棋不多。
会围棋的不懂编程,懂编程的不会围棋,这是个问题,本人围棋比编程水平高,呵呵。
有同好的朋友,请留言一起玩玩手机围棋。
url:http://greatverve.cnblogs.com/archive/2011/12/29/java-window-hello-world.html#
用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();
}
}
});
}
}
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();
}
}
});
}
}
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。