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);
}
}
}
});
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);
}
}
}
});
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();
}
});
sp.addPropertyChangeListener(
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if (e.getPropertyName().equals(JSplitPane.DIVIDER_LOCATION_PROPERTY)) {
//do your bussiness
}
}
}
);
public void componentResized(ComponentEvent e) {
......
//Your Code here
}
});试下。;)