package exceise;
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
public class BorderLayoutPosition extends JFrame{
String[] border= {BorderLayout.CENTER,
BorderLayout.NORTH,
BorderLayout.SOUTH,BorderLayout.WEST,
BorderLayout.WEST,BorderLayout.EAST};
String[] buttonName= {"center button","north button","south button","west button"
,"east button"};
public BorderLayoutPosition() {
setTitle("使用边界管理器");
Container c=getContentPane();//设置一个容器
setLayout(new BorderLayout());
for(int i=0;i<border.length;i++) {
c.add(border[i],new JButton(buttonName[i]));
}
setSize(350,200);
setVisible(true);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
}
public static void main(String[] args) {
new BorderLayoutPosition();
}
}
加粗下划线的地方报错,main函数无法识别