RT,说一下思路不一定写全代码

解决方案 »

  1.   

    使用JSplitPane窗体分割。具体用法你查查API。
      

  2.   


    JSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent) 
              创建一个具有指定方向和不连续重绘的指定组件的新 JSplitPane。setDividerLocation(double proportionalLocation) 
              设置分隔条的位置为 JSplitPane 大小的一个百分比。
      

  3.   

    import java.awt.*;
    import javax.swing.*;public class Test extends JFrame {
        
        public Test() {
            JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(new JButton("One")), new JScrollPane(new JButton("Two")));
            //splitter.setDividerLocation(0.66); // Don't work.
            
            this.getContentPane().add(splitter);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setSize(400, 400);
            this.setVisible(true);
            splitter.setDividerLocation(0.66); // OK
        }
        
        public static void main(String[] args) {
            new Test();
        }
    }