哪位高手能帮我解决一个问题?
我想将一个窗口三等分,并且可以像JSplitPane那样用鼠标拖动分割线可以改变比例。急需帮助......
祝福所有帮我的大哥大姐新年快乐,Happy everyday,Happy everything!
这是我的代码:import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TestDivide extends JFrame{
     public TestDivide() {
Container cp=getContentPane();
JSplitPane   js=new     JSplitPane();
JSplitPane   js1=new     JSplitPane();
JPanel   jp1=new   JPanel();
jp1.setBackground(Color.green);
JPanel   jp2=new   JPanel();
jp2.setBackground(Color.yellow);
JPanel   jp3=new   JPanel();
jp3.setBackground(Color.pink);
js1.setLeftComponent(jp1);
js1.setRightComponent(jp2);
js.setLeftComponent(js1);
js.setRightComponent(jp3);
cp.add(js);
setSize(400,300);
setVisible(true);
}
     public static void main(String sd[]){
      TestDivide frm=new TestDivide();
     }
}这样运行以后右边的JPanel特别大,左边的两个特别小,这是为什么?能不能通过设置,刚开始就是三等分?当然,如果能设置成中间大一点,两边小一点最好,这是我最想要的结果。

解决方案 »

  1.   

    怎么做我不会 哈,不过可以推荐你用NetBeans7.0,里面有一个新的功能就是可以自由拖拽,设置窗口和面板的样式。
      

  2.   

    谢谢,这个我们老师提高过,Eclipseue也有一个这样的插件,但不推荐这样用,这样不便管理布局,而且写出的代码不规范,学习阶段最好还是老老实实自己写代码。
      

  3.   

    自己绘制?
    Swing不怎么了解,等待高手。
      

  4.   

    这样的效果?import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class TestDivide extends JFrame{
         public TestDivide() {
            Container cp=getContentPane();
            JSplitPane   js=new     JSplitPane();
            JSplitPane   js1=new     JSplitPane();
            JPanel   jp1=new   JPanel();
            jp1.setBackground(Color.green);
            JPanel   jp2=new   JPanel();
            jp2.setBackground(Color.yellow);
            JPanel   jp3=new   JPanel();
          
            jp3.setBackground(Color.pink);
            js1.setLeftComponent(jp1);
            js1.setRightComponent(jp2);
            js1.setDividerLocation(100);         js.setLeftComponent(js1);
            js.setRightComponent(jp3);
            js.setDividerLocation(300);         cp.add(js);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setSize(400,300);
            setVisible(true);
        }
         public static void main(String sd[]){
             TestDivide frm=new TestDivide();
         }
    }