Java 怎么测试BorderLayout

2019年7月13日22:35:47 评论 72

1.简介

Java 怎么测试BorderLayout?——请看下文。

2.代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */
import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class Main extends JFrame {

  public Main() {
    super("Border");
    setSize(240, 280);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setLayout(new BorderLayout());
    JButton nButton = new JButton("North");
    JButton sButton = new JButton("South");
    JButton eButton = new JButton("East");
    JButton wButton = new JButton("West");
    JButton cButton = new JButton("Center");
    add(nButton, BorderLayout.NORTH);
    add(sButton, BorderLayout.SOUTH);
    add(eButton, BorderLayout.EAST);
    add(wButton, BorderLayout.WEST);
    add(cButton, BorderLayout.CENTER);
    setVisible(true);
  }

  public static void main(String[] arguments) {
    Main frame = new Main();
  }
}

 

3.总结

示例代码演示了 Java 怎么测试BorderLayout,具体步骤参见示例代码。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: