baseGraphScrollPane和ratioGraphScrollPane是两个JScrollPane,设置其初始大小,如下:baseGraphScrollPane.setPreferredSize(new Dimension(
      this.BASE_GRAPH_PANEL_X, this.BASE_GRAPH_PANEL_Y));
ratioGraphScrollPane.setPreferredSize(new Dimension(
      this.BASE_GRAPH_PANEL_X, this.BASE_GRAPH_PANEL_Y));将baseGraphScrollPane和ratioGraphScrollPane放置到JSplitPane中,拖拽JSplitPane的边界改变两个JScrollPane的大小,请问在JSplitPane中触发什么事件来记录这一操作,我做这一操作主要是想通过getPreferredSize()得到baseGraphScrollPane和ratioGraphScrollPane的托拽后的大小值。另外,getPreferredSize()是否能得到拖拽后组件的大小final JSplitPane graphSplitPane = new JSplitPane(
                JSplitPane.VERTICAL_SPLIT, baseGraphScrollPane,
                ratioGraphScrollPane);
        graphSplitPane.setDividerLocation(this.BASE_DATA_PANEL_Y
                + this.BASE_GRAPH_PANEL_Y);
        graphSplitPane.setOneTouchExpandable(true);
        Component divider4 = getSplitDivider(graphSplitPane);
        divider4.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    if (ratioGraphScrollPane.isVisible()) {
                        graphSplitPane.setDividerLocation(1.0);
                    }
                }
            }
        });

解决方案 »

  1.   

    top = new JScrollPane(new JTextArea());        JViewport vp = top.getViewport();        vp.addChangeListener(new ChangeListener(){
                public void stateChanged(ChangeEvent e) {
                    JViewport evp = (JViewport)e.getSource();                System.out.println(evp.getViewPosition());
                    System.out.println(evp.getViewSize());
                    System.out.println(evp.getExtentSize());
                    System.out.println();
                }
            });
      

  2.   

    应该是和JSplitPane有关的事件吧,你的没试,我已经找到了,谢谢楼上的 JSplitPane   sp   =   new   JSplitPane();   
      sp.addPropertyChangeListener(   
          new   PropertyChangeListener()   {   
              public   void   propertyChange(PropertyChangeEvent   e)   {   
                  if   (e.getPropertyName().equals(JSplitPane.DIVIDER_LOCATION_PROPERTY))   {   
                      //do   your   bussiness   
                  }   
              }   
          }   
      );
      

  3.   

    SplitPane.addComponentListener(new   java.awt.event.ComponentAdapter()   {   
                  public   void   componentResized(ComponentEvent   e)   {   
                      ......   
                      //Your   Code   here   
                  }   
              });试下。;)