📄 guidemo2.java
字号:
//Example 2 of Chapter 5
import java.awt.*;
import javax.swing.*;
public class GUIDemo2
{
public static void main(String[] args)
{
JFrame f = new JFrame("FlowLayout布局管理器演示");
JPanel contentpane = new JPanel();
JButton bred = new JButton("red");
JButton bgreen = new JButton("green");
JButton bblue = new JButton("blue");
JButton bcyan = new JButton("cyan");
JButton bmagenta = new JButton("magenta");
JButton byellow = new JButton("yellow");
bred.setBackground(Color.red);
bgreen.setBackground(Color.green);
bblue.setBackground(Color.blue);
bcyan.setBackground(Color.cyan);
bmagenta.setBackground(Color.magenta);
byellow.setBackground(Color.yellow);
contentpane.setLayout(new FlowLayout(FlowLayout.LEFT));
f.setContentPane(contentpane);
contentpane.add(bred);
contentpane.add(bgreen);
contentpane.add(bblue);
contentpane.add(bcyan);
contentpane.add(bmagenta);
contentpane.add(byellow);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize( 600 , 100 );
f.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -