📄 borderlayoutdemo.java
字号:
import java.awt.*;
import javax.swing.*;
public class BorderLayoutDemo extends JFrame
{
private String microsoft = "Microsoft ";
private String word = "Word ";
private String excel = "Excel ";
private String powerPoint = "PowerPoint ";
private String frontPage = "FrontPage ";
private JButton microsoftButton,wordButton,excelButton,powerPointButton,
frontPageButton;
public BorderLayoutDemo()
{
super( "BorderLayoutDemo" );
Container container = getContentPane();
// 创建按钮
microsoftButton = new JButton( microsoft );
wordButton = new JButton( word );
excelButton = new JButton( excel );
powerPointButton = new JButton( powerPoint );
frontPageButton = new JButton( frontPage );
// 将按钮加入container中
container.add( microsoftButton,BorderLayout.CENTER );
container.add( wordButton,BorderLayout.WEST );
container.add( excelButton,BorderLayout.EAST );
container.add( powerPointButton,BorderLayout.NORTH );
container.add( frontPageButton,BorderLayout.SOUTH );
setSize( 260,120 );
setVisible( true );
}
public static void main(String[] args)
{
BorderLayoutDemo borderLayoutDemo = new BorderLayoutDemo();
borderLayoutDemo.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -