private static void drawSelection(JTree tree, Graphics g, final int width) {
   int y = 0;
   final int[] rows = tree.getSelectionRows();
   final int height = tree.getRowHeight();
   for (int row : rows) {
     final TreeCellRenderer renderer = tree.getCellRenderer();
     final Object value = tree.getPathForRow(row).getLastPathComponent();
     if (value == null) continue;
     final Component component =
         renderer.getTreeCellRendererComponent(tree, value, false, false, false, row, false);
     if (component.getFont() == null) {
       component.setFont(tree.getFont());
     }
     g.translate(0, y);
     component.setBounds(0, 0, width, height);
     boolean wasOpaque = false;
     if (component instanceof JComponent) {
       final JComponent j = (JComponent) component;
       if (j.isOpaque()) wasOpaque = true;
       j.setOpaque(false);
     }
     component.paint(g);
     if (wasOpaque) {
       ((JComponent) component).setOpaque(true);
     }
     y += height;
     g.translate(0, -y);
   }
 }
 /**
  * Returns the size style of a specified component.
  *
  * @return REGULAR, SMALL or MINI.
  */
 private int getSizeStyle(Component c) {
   // Aqua components have a different style depending on the
   // font size used.
   // 13 Point = Regular
   // 11 Point = Small
   //  9 Point = Mini
   if (c == null) {
     return REGULAR;
   }
   Font font = c.getFont();
   if (font == null) {
     return REGULAR;
   }
   int fontSize = font.getSize();
   return (fontSize >= 13) ? REGULAR : ((fontSize > 9) ? SMALL : MINI);
 }