private static class MyJTree extends JTree { ... public void invalidateNodeBoundsViaSideEffect() { if (ui instanceof BasicTreeUI) { BasicTreeUI basicTreeUI = (BasicTreeUI) ui; basicTreeUI.setLeftChildIndent(basicTreeUI.getLeftChildIndent()); }} public void invalidateNodeBoundsViaRefection() { if (ui instanceof BasicTreeUI) { try { Field field = BasicTreeUI.class.getDeclaredField("treeState"); field.setAccessible(true); AbstractLayoutCache treeState = (AbstractLayoutCache) field.get(ui); if (treeState != null) { treeState.invalidateSizes(); } } catch (Exception e) { } }}}
@Override public void setUI(TreeUI ui) { super.setUI(ui); if (ui instanceof BasicTreeUI) { BasicTreeUI bui = (BasicTreeUI)ui; treeHandleWidth = bui.getLeftChildIndent() + bui.getRightChildIndent(); } else { treeHandleWidth = -1; } }
/** * If a negative number is returned, then all events that occur in the * leading margin will be forwarded to the tree and consumed. * * @return the width of the tree handle if it can be determined, else -1 */ protected int getTreeHandleWidth() { if (renderer.getUI() instanceof BasicTreeUI) { BasicTreeUI ui = (BasicTreeUI) renderer.getUI(); return ui.getLeftChildIndent() + ui.getRightChildIndent(); } else { return -1; } }
/** * If a negative number is returned, then all events that occur in the * leading margin will be forwarded to the tree and consumed. * * @return the width of the tree handle if it can be determined, else -1 */ protected int getTreeHandleWidth() { if (renderer.getUI() instanceof BasicTreeUI) { BasicTreeUI ui = (BasicTreeUI) renderer.getUI(); return ui.getLeftChildIndent() + ui.getRightChildIndent(); } else { return -1; } }
/** * If a negative number is returned, then all events that occur in the * leading margin will be forwarded to the tree and consumed. * * @return the width of the tree handle if it can be determined, else -1 */ protected int getTreeHandleWidth() { if (renderer.getUI() instanceof BasicTreeUI) { BasicTreeUI ui = (BasicTreeUI) renderer.getUI(); return ui.getLeftChildIndent() + ui.getRightChildIndent(); } else { return -1; } }
/** * If a negative number is returned, then all events that occur in the * leading margin will be forwarded to the tree and consumed. * * @return the width of the tree handle if it can be determined, else -1 */ protected int getTreeHandleWidth() { if (renderer.getUI() instanceof BasicTreeUI) { BasicTreeUI ui = (BasicTreeUI) renderer.getUI(); return ui.getLeftChildIndent() + ui.getRightChildIndent(); } else { return -1; } }
/** * Invalidates cell size caching in the ui delegate. May do nothing if there's no * safe (i.e. without reflection) way to message the delegate. <p> * * This implementation calls BasicTreeUI setLeftChildIndent with the old indent if available. * Beware: clearing the cache is an undocumented implementation side-effect of the * method. Revisit if we ever should have a custom ui delegate. * * */ public void invalidateCellSizeCache() { if (getUI() instanceof BasicTreeUI) { BasicTreeUI ui = (BasicTreeUI) getUI(); ui.setLeftChildIndent(ui.getLeftChildIndent()); } }
/** * Invalidates cell size caching in the ui delegate. May do nothing if there's no * safe (i.e. without reflection) way to message the delegate. <p> * * This implementation calls BasicTreeUI setLeftChildIndent with the old indent if available. * Beware: clearing the cache is an undocumented implementation side-effect of the * method. Revisit if we ever should have a custom ui delegate. * * */ public void invalidateCellSizeCache() { if (getUI() instanceof BasicTreeUI) { BasicTreeUI ui = (BasicTreeUI) getUI(); ui.setLeftChildIndent(ui.getLeftChildIndent()); } }
/** Make a path visible. * @param path the path */ private void showPathWithoutExpansion(TreePath path) { Rectangle rect = tree.getPathBounds(path); if (rect != null) { //PENDING TreeUI tmp = tree.getUI(); int correction = 0; if (tmp instanceof BasicTreeUI) { correction = ((BasicTreeUI) tmp).getLeftChildIndent(); correction += ((BasicTreeUI) tmp).getRightChildIndent(); } rect.x = Math.max(0, rect.x - correction); if (rect.y >= 0) { //#197514 - do not scroll to negative y values tree.scrollRectToVisible(rect); } } }
/** * Invalidates cell size caching in the ui delegate. May do nothing if there's no * safe (i.e. without reflection) way to message the delegate. <p> * * This implementation calls BasicTreeUI setLeftChildIndent with the old indent if available. * Beware: clearing the cache is an undocumented implementation side-effect of the * method. Revisit if we ever should have a custom ui delegate. * * */ public void invalidateCellSizeCache() { if (getUI() instanceof BasicTreeUI) { BasicTreeUI ui = (BasicTreeUI) getUI(); ui.setLeftChildIndent(ui.getLeftChildIndent()); } }
/** * Invalidates cell size caching in the ui delegate. May do nothing if there's no * safe (i.e. without reflection) way to message the delegate. <p> * * This implementation calls BasicTreeUI setLeftChildIndent with the old indent if available. * Beware: clearing the cache is an undocumented implementation side-effect of the * method. Revisit if we ever should have a custom ui delegate. * * */ public void invalidateCellSizeCache() { if (getUI() instanceof BasicTreeUI) { BasicTreeUI ui = (BasicTreeUI) getUI(); ui.setLeftChildIndent(ui.getLeftChildIndent()); } }
private boolean isLocationInExpandControl( TreePath path, Point location ) { if( tree.getModel().isLeaf( path.getLastPathComponent() ) ) return false; Rectangle r = tree.getPathBounds(path); int boxWidth = 8; Insets i = tree.getInsets(); int indent = 0; if( tree.getUI() instanceof BasicTreeUI ) { BasicTreeUI ui = (BasicTreeUI)tree.getUI(); if( null != ui.getExpandedIcon() ) boxWidth = ui.getExpandedIcon().getIconWidth(); indent = ui.getLeftChildIndent(); } int boxX; if( tree.getComponentOrientation().isLeftToRight() ) { boxX = r.x - positionX - indent - boxWidth; } else { boxX = r.x - positionX + indent + r.width; } return location.getX() >= boxX && location.getX() <= (boxX + boxWidth); } }
if (ui instanceof BasicTreeUI) { BasicTreeUI basicTreeUI = (BasicTreeUI) ui; basicTreeUI.setLeftChildIndent(basicTreeUI.getLeftChildIndent());
if (ui instanceof BasicTreeUI) { BasicTreeUI basic = (BasicTreeUI) ui; basic.setLeftChildIndent(basic.getLeftChildIndent());