public void doLayout() { if (view != null) { view.setSize(view.getPreferredSize()); visibleRect = getVisibleRect(); view.setLocation(visibleRect.x, visibleRect.y); } glassPane.setLocation(0, 0); glassPane.setSize(getWidth(), getHeight()); }
private static Pair<Image, Point> createDragImage( final Tree tree, final Component c, Point dragOrigin, boolean adjustToPathUnderDragOrigin) { if (c instanceof JComponent) { ((JComponent) c).setOpaque(true); } c.setForeground(tree.getForeground()); c.setBackground(tree.getBackground()); c.setFont(tree.getFont()); c.setSize(c.getPreferredSize()); final BufferedImage image = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = (Graphics2D) image.getGraphics(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f)); c.paint(g2); g2.dispose(); Point point = new Point(-image.getWidth(null) / 2, -image.getHeight(null) / 2); if (adjustToPathUnderDragOrigin) { TreePath path = tree.getPathForLocation(dragOrigin.x, dragOrigin.y); if (path != null) { Rectangle bounds = tree.getPathBounds(path); point = new Point(bounds.x - dragOrigin.x, bounds.y - dragOrigin.y); } } return new Pair<Image, Point>(image, point); }
// not used public Component add(Component c) { // System.out.println("Add " + c); if (c instanceof AbstractButton) { // System.out.println("Add to button group " + c); c.setVisible(true); bg.add((AbstractButton) c); } if (c instanceof Anchorable && ((Anchorable) c).isAnchored()) { c.setSize(c.getPreferredSize()); } return super.add(c); }