flowlayouttest.java

来自「java GUI用户界面程序」· Java 代码 · 共 44 行

JAVA
44
字号
package chapter7.layout;

import java.awt.*;
import javax.swing.JButton;

public class FlowLayoutTest
    extends Frame
{
    FlowLayout flowLayout1 = new FlowLayout();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JButton jButton3 = new JButton();
    public FlowLayoutTest()
    {
        try
        {
            jbInit();
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }
    }

    private void jbInit()
        throws Exception
    {
        this.setLayout(flowLayout1);
        jButton1.setText("jButton1");
        jButton2.setText("jButton2");
        jButton3.setText("jButton3");
        this.add(jButton1);
        this.add(jButton2);
        this.add(jButton3);
    }

    public static void main(String[] args)
    {
        FlowLayoutTest flow = new FlowLayoutTest();
        flow.setSize(300,80);
        flow.setVisible(true);
    }
}

⌨️ 快捷键说明

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