如何在其JSplitPane中创建此FlowLayout包装?

Maa*_*arx 1 java swing layout-manager

我编写了这段代码示例来说明我在程序中遇到的问题.

我希望能够将JSplitPane的滑块向左滑动,超出按钮的边缘,压缩该JPanel,并让FlowLayout将按钮包裹到第二行.

相反,JSplitPane不允许我将滑块移动到屏幕上最右边的按钮,如果我调整整个JFrame的大小以强制压缩,按钮(我推测)只是在JPanel的右侧运行,下面是滑杆(我猜,因为我显然看不到它们).

我究竟做错了什么?

import java.awt.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
public class Driver implements Runnable {
    public static void main(String[] args) {
        (new Driver()).run();
    }
    public void run() {
        try {
            go();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }
    private void go() throws Exception {
        JFrame jframe = new JFrame("FlowLayoutTest");
        JPanel left = new JPanel();
        left.setBackground(Color.RED);
        left.setLayout(new BorderLayout());
        JPanel right = new JPanel();
        right.setBackground(Color.BLUE);
        right.setLayout(new BorderLayout());
        JSplitPane topmost =
            new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right);
        jframe.setContentPane(topmost);
        JPanel bottomleft = new JPanel();
        bottomleft.setBackground(Color.GREEN);
        bottomleft.setLayout(new FlowLayout());
        left.add(bottomleft, BorderLayout.PAGE_END);
        for (int i = 0; i < 10; i++) {
            bottomleft.add(new JButton("" + i));
        }
        jframe.pack();
        jframe.setVisible(true);
        jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
Run Code Online (Sandbox Code Playgroud)

cam*_*ckr 7

除了FlowLayout之外还有其他布局管理器可以完成我正在寻找的东西吗?

换行布局应该有效.