Package javax.swing.plaf.basic

Examples of javax.swing.plaf.basic.BasicTreeUI


         *
         * @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;
            }
        }
View Full Code Here


     *
     *
     */
    public void invalidateCellSizeCache() {
        if (getUI() instanceof BasicTreeUI) {
            BasicTreeUI ui = (BasicTreeUI) getUI();
            ui.setLeftChildIndent(ui.getLeftChildIndent());
        }
    }
View Full Code Here

            directory = parentTree;
        }
       
        // This is a workaround to an apparent bug in BasicTreeUI; see also
        // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6505523
        directory.setUI(new BasicTreeUI() {
            @Override
            protected AbstractLayoutCache createLayoutCache() {
                return new VariableHeightLayoutCache() {
                    @Override
                    public Rectangle getBounds(TreePath arg0, Rectangle arg1) {
View Full Code Here

  @Nullable
  public static Range<Integer> getExpandControlRange(final JTree aTree, final TreePath path) {
    TreeModel treeModel = aTree.getModel();

    final BasicTreeUI basicTreeUI = (BasicTreeUI)aTree.getUI();
    Icon expandedIcon = basicTreeUI.getExpandedIcon();


    Range<Integer> box = null;
    if (path != null && !treeModel.isLeaf(path.getLastPathComponent())) {
      int boxWidth;
      Insets i = aTree.getInsets();

      if (expandedIcon != null) {
        boxWidth = expandedIcon.getIconWidth();
      }
      else {
        boxWidth = 8;
      }

      int boxLeftX = i != null ? i.left : 0;

      boolean leftToRight = aTree.getComponentOrientation().isLeftToRight();
      int depthOffset = getDepthOffset(aTree);
      int totalChildIndent = basicTreeUI.getLeftChildIndent() + basicTreeUI.getRightChildIndent();

      if (leftToRight) {
        boxLeftX += ((path.getPathCount() + depthOffset - 2) * totalChildIndent + basicTreeUI.getLeftChildIndent()) -
            boxWidth / 2;
      }
      int boxRightX = boxLeftX + boxWidth;

      box = new Range<Integer>(boxLeftX, boxRightX);
View Full Code Here

        defaults.put("Tree[Enabled].expandedIconPainter", expandedIconPainter);
        defaults.put("Tree:TreeCell[Focused+Selected].backgroundPainter", new SelectionBackgroundPainter(renderer.getBackgroundSelectionColor()));

        TreeUI treeUI = getUI();
        if (treeUI instanceof MetalTreeUI) {
            BasicTreeUI basicUI = (BasicTreeUI) treeUI;
            int size = 7;
            BufferedImage expandedIcon = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
            expandedIconPainter.paint(expandedIcon.createGraphics(), null, size, size);
            BufferedImage collapsedIcon = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
            collapsedIconPainter.paint(collapsedIcon.createGraphics(), null, size, size);
            basicUI.setCollapsedIcon(new ImageIcon(collapsedIcon));
            basicUI.setExpandedIcon(new ImageIcon(expandedIcon));
        }

        putClientProperty("Nimbus.Overrides", defaults);
        putClientProperty("Nimbus.Overrides.InheritDefaults", true);
    }
View Full Code Here

        defaults.put("Tree[Enabled].expandedIconPainter", expandedIconPainter);
        defaults.put("Tree:TreeCell[Focused+Selected].backgroundPainter", new SelectionBackgroundPainter(renderer.getBackgroundSelectionColor()));

        TreeUI treeUI = getUI();
        if (treeUI instanceof MetalTreeUI) {
            BasicTreeUI basicUI = (BasicTreeUI) treeUI;
            int size = 7;
            BufferedImage expandedIcon = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
            expandedIconPainter.paint(expandedIcon.createGraphics(), null, size, size);
            BufferedImage collapsedIcon = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
            collapsedIconPainter.paint(collapsedIcon.createGraphics(), null, size, size);
            basicUI.setCollapsedIcon(new ImageIcon(collapsedIcon));
            basicUI.setExpandedIcon(new ImageIcon(expandedIcon));
        }

        putClientProperty("Nimbus.Overrides", defaults);
        putClientProperty("Nimbus.Overrides.InheritDefaults", true);
    }
View Full Code Here

        }
      }
    });

    putClientProperty("JTree.lineStyle", "Angled");
    setUI(new BasicTreeUI());   // In WindowsXP UI handles are not shown :(
  }
View Full Code Here

TOP

Related Classes of javax.swing.plaf.basic.BasicTreeUI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.