📄 demoborderlayout.java
字号:
/*
* DemoBorderLayout.java
*
* Created on 2007年7月31日, 下午9:26
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package org.Adam;
import java.awt.*;
import javax.swing.*;
/**
*
* @author Administrator
*/
public class DemoBorderLayout extends JFrame {
private JLabel jLabelEast,jLabelWest,jLabelNorth,jLabelCenter;
private JPanel jPanelSouth;
private JButton jButtonOne,jButtonTwo,jButtonThree;
/** Creates a new instance of DemoBorderLayout */
public DemoBorderLayout() {
BorderLayout myBorderLayout=new BorderLayout(5,5);
this.setLayout(myBorderLayout);
jLabelEast=new JLabel("this is East area");
jLabelWest=new JLabel("this is West area");
jLabelNorth=new JLabel("this is North area");
jLabelCenter=new JLabel("this is Center area");
jLabelEast.setHorizontalAlignment(SwingConstants.CENTER);
jLabelWest.setHorizontalAlignment(SwingConstants.CENTER);
jLabelNorth.setHorizontalAlignment(SwingConstants.CENTER);
jLabelCenter.setHorizontalAlignment(SwingConstants.CENTER);
jButtonOne=new JButton("ButtonOne");
jButtonTwo=new JButton("ButtonTwo");
jButtonThree=new JButton("ButtonThree");
jPanelSouth=new JPanel();
jPanelSouth.setLayout(new FlowLayout());
jPanelSouth.add(jButtonOne);
jPanelSouth.add(jButtonTwo);
jPanelSouth.add(jButtonThree);
this.add(jLabelEast,BorderLayout.EAST);
this.add(jLabelWest,BorderLayout.WEST);
this.add(jLabelNorth,BorderLayout.NORTH);
this.add(jLabelCenter,BorderLayout.CENTER);
this.add(jPanelSouth,BorderLayout.SOUTH);
this.setTitle("BorderLayout应用完整示例");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new DemoBorderLayout().setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -