⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flowlayoutdemo.java

📁 《精通Java Swing程序设计S》这本书所附带的JAVA程序写得很漂亮,都是SWING的实例子,很适合初学者。
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class FlowLayoutDemo {
     
    public FlowLayoutDemo() {
    
    	JFrame f = new JFrame();
    	
        Container contentPane = f.getContentPane();
        contentPane.setLayout(new FlowLayout());
        contentPane.add(new JButton("first"));  
        contentPane.add(new JButton("second"));
        contentPane.add(new JButton("third"));
        contentPane.add(new JButton("fourth"));
        contentPane.add(new JButton("fifth"));
        contentPane.add(new JButton("This is the last button"));

	    f.setTitle("FlowLayout");
	    f.setSize(getPreferredSize());
        f.setVisible(true);
        
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                    System.exit(0);
            }
        });
    }

    public Dimension getPreferredSize()
    {
        return new Dimension(200, 200);
    }
    
    public static void main(String args[]) {
    
        FlowLayoutDemo b = new FlowLayoutDemo();
        
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -