splitpane.java

来自「由于想一次上传成功 所以将二个教程打包成了一个 这些例子几乎包含了所有java的」· Java 代码 · 共 56 行

JAVA
56
字号
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

/*
<APPLET
    CODE = splitpane.class
    WIDTH = 600
    HEIGHT = 200 >
</APPLET>
*/

public class splitpane extends JApplet implements ActionListener
{
    JButton jbutton1, jbutton2, jbutton3;
    JTextField text1 = new JTextField("Text 1");
    JTextField text2 = new JTextField("Text 2");
    JSplitPane jsplitpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, 
        text1, text2);

    public void init()
    {
        Container contentPane = getContentPane();
        JPanel jpanel = new JPanel();

        jbutton1 = new JButton("Make one-touch expandable");
        jbutton1.addActionListener(this);
        jpanel.add(jbutton1);

        jbutton2 = new JButton("Make split horizontal");
        jbutton2.addActionListener(this);
        jpanel.add(jbutton2);

        jbutton3 = new JButton("Increase divider size");
        jbutton3.addActionListener(this);
        jpanel.add(jbutton3);

        contentPane.add(jsplitpane, BorderLayout.CENTER);
        contentPane.add(jpanel, BorderLayout.SOUTH);
    }

    public void actionPerformed(ActionEvent e)
    {
        if(e.getSource() == jbutton1) {
            jsplitpane.setOneTouchExpandable(true);
        }
        if(e.getSource() == jbutton2) {
            jsplitpane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
        }
        if(e.getSource() == jbutton3) {
            jsplitpane.setDividerSize(jsplitpane.getDividerSize() + 10);
        }
    }
}

⌨️ 快捷键说明

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