JavaSE series code 43: Use of BorderLayout class

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);
  }
}
Published 52 original articles · Like 162 · Visitors 10,000+

Guess you like

Origin blog.csdn.net/blog_programb/article/details/105394495