separatorexample.java

来自「java swing 开发代码」· Java 代码 · 共 43 行

JAVA
43
字号
// SeparatorExample.java// A quick demonstration of the JSeparator() component used in a toolbar-like// container.//package	jswing.ch14;import javax.swing.*;public class SeparatorExample extends JPanel {    public SeparatorExample() {        super(true);        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));        Box box1 = new Box(BoxLayout.X_AXIS);        Box box2 = new Box(BoxLayout.X_AXIS);        Box box3 = new Box(BoxLayout.X_AXIS);        box1.add(new JButton("Press Me"));        box1.add(new JButton("No Me!"));        box1.add(new JButton("Ignore Them!"));        box2.add(new JSeparator());        box3.add(new JButton("I'm the Button!"));        box3.add(new JButton("It's me!"));        box3.add(new JButton("Go Away!"));        add(box1);        add(box2);        add(box3);    }    public static void main(String s[]) {        SeparatorExample example = new SeparatorExample();        JFrame frame = new JFrame("Separator Example");        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        frame.setContentPane(example);        frame.pack();        frame.setVisible(true);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?