JavaSE系列代码43:BorderLayout类的使用

The abstract class cannot create an object with the new operator, it must produce its subclass, which creates the object. If there is an abstract method in the class body of an abstract class, it can only be declared but not implemented. The subclass of the class must implement the abstract method, that is, override the abstract method of the parent class. An abstract class only cares about whether a subclass has a certain function, not about the specific implementation of the function. The specific implementation is the responsibility of the subclass.

import java.awt.*; 
public class Javase_43 extends Frame
{
  static Frame frm=new Frame("边界式布局管理器BorderLayout");
  public static void main(String[] args)
  {
    BorderLayout border=new BorderLayout (5,10);
    frm.setLayout(border);      //设置页面布局为边界式布局方式
    frm.setSize(280,200);
    frm.add(new Button("上北"), BorderLayout.NORTH);
    frm.add(new Button("下南"), BorderLayout. SOUTH);
    frm.add(new Button("左西"), BorderLayout.WEST);
    frm.add(new Button("右东"), BorderLayout.EAST);
    frm.add(new Button("中央"), BorderLayout.CENTER);
    frm.setVisible(true);
  }
}
发布了52 篇原创文章 · 获赞 162 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/blog_programb/article/details/105394495