应该用布局管理器就可以实现。

解决方案 »

  1.   

    这个不是属于JFrame所要做的事,而是属于JSpilder
    下面的方法,我也不确定,还希望高手出来指点
    package Dekn;import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;/**
     * <p>Title: Dekn</p>
     * <p>Description: 研究</p>
     * <p>Copyright: Copyright (c) 2003</p>
     * <p>Company: Dekn</p>
     * @author Dekn
     * @version 1.0
     */public class Frame5 extends JFrame {
      JPanel contentPane;
      BorderLayout borderLayout1 = new BorderLayout();
      JSplitPane jSplitPane1 = new JSplitPane();  //Construct the frame
      public Frame5() {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      //Component initialization
      private void jbInit() throws Exception  {
        contentPane = (JPanel) this.getContentPane();
        contentPane.setLayout(borderLayout1);
        this.setSize(new Dimension(400, 300));
        this.setTitle("Frame Title");
        jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
        jSplitPane1.setResizeWeight(0.8);
        contentPane.add(jSplitPane1, BorderLayout.CENTER);
        jSplitPane1.setDividerLocation(240);
      }
      //Overridden so we can exit when window is closed
      protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
          System.exit(0);
        }
      }
    }