下面列出了javax.swing.JSplitPane#getDividerLocation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Returns true if the frame is maximized
* @return
*/
public boolean isMaximized(){
if(this.getParent() instanceof JSplitPane){
JSplitPane split = ((JSplitPane)this.getParent());
if(split.getTopComponent() == this){
if(split.getDividerLocation() == split.getHeight() - (gradientPanel.getHeight() + split.getDividerSize() + SPLIT_MARGIN)){
logger.debug("is a maximized top component");
return true;
} else {
logger.debug("is not a maximized component, but it is a top component");
return false;
}
} else {
if(split.getDividerLocation() == gradientPanel.getHeight()){
logger.debug("is a maximized bottom component");
return true;
} else {
logger.debug("is not a maximized component, but is is a bottom component");
return false;
}
}
} else {
throw new IllegalStateException("SimpleInternalFrame is not on a split pane");
}
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
@Override
protected void mouseButton1Pressed(MouseEvent me) {
JSplitPane c = (JSplitPane) (component instanceof JSplitPane ? component
: SwingUtilities.getAncestorOfClass(JSplitPane.class, component));
if (c == null) {
return;
}
dividerLocation = c.getDividerLocation();
}
@Override
protected void mouseReleased(MouseEvent me) {
JSplitPane c = (JSplitPane) (component instanceof JSplitPane ? component
: SwingUtilities.getAncestorOfClass(JSplitPane.class, component));
if (c == null || dividerLocation == c.getDividerLocation()) {
return;
}
RComponent rComponent = new RComponentFactory(omapConfig).findRComponent(c, null, recorder);
recorder.recordSelect(rComponent, "" + c.getDividerLocation());
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
private static void test(JSplitPane pane, String action, int expected) {
ActionEvent event = new ActionEvent(pane, expected, action);
pane.getActionMap().get(action).actionPerformed(event);
int actual = pane.getDividerLocation();
if (actual != expected) {
throw new Error(actual + ", but expected " + expected);
}
}
void grab(JSplitPane cmp) {location = cmp.getDividerLocation();}