frame1.java

来自「jbuilder2005」· Java 代码 · 共 42 行

JAVA
42
字号
package flowlayouttest;

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

public class Frame1
    extends JFrame {
  JPanel contentPane;
  FlowLayout flowLayout1 = new FlowLayout();
//    FlowLayout flowLayout1 = new FlowLayout(FlowLayout.LEFT);  //对齐方式
  Button button1 = new Button();
  Button button2 = new Button();
  Button button3 = new Button();
  public Frame1() {
    try {
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      jbInit();
    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
  }

  /**
   * Component initialization.
   *
   * @throws java.lang.Exception
   */
  private void jbInit() throws Exception {
    contentPane = (JPanel) getContentPane();
    contentPane.setLayout(flowLayout1);
    setSize(new Dimension(180, 90));
    setTitle("FlowLayout");
    button1.setLabel("OK");
    button2.setLabel("Open");
    button3.setLabel("Close");
    contentPane.add(button1);
    contentPane.add(button2);
    contentPane.add(button3);
  }
}

⌨️ 快捷键说明

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