borderlayoutdemo.java
来自「java2参考大全上的例子的源码和自己的理解.」· Java 代码 · 共 30 行
JAVA
30 行
import java.awt.*;import java.applet.*;import java.util.*;public class BorderLayoutDemo extends Applet{ public void init() { //A border layout lays out a container, arranging and resizing its components to fit in five regions: //north, south, east, west, and center. Each region may contain no more than one component, //and is identified by a corresponding constant: NORTH, SOUTH, EAST, WEST, and CENTER. //When adding a component to a container with a border layout, use one of these five constants, //for example: Panel p = new Panel(); //p.setLayout(new BorderLayout()); //p.add(new Button("Okay"), BorderLayout.SOUTH); setLayout(new BorderLayout()); add(new Button("This is arross the top"), BorderLayout.NORTH); add(new Label("The message is on the bottom"), BorderLayout.SOUTH); add(new Button("Left"),BorderLayout.WEST); add(new Button("Right"),BorderLayout.EAST); String message="This is the message in the Center!"; add(new TextArea(message),BorderLayout.CENTER); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?