< prev index next >

src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java

Print this page




 186             return new CollapsedIcon();
 187         }
 188 
 189         public void paintIcon(Component c, Graphics g, int x, int y) {
 190             Skin skin = getSkin(c);
 191             if (skin != null) {
 192                 skin.paintSkin(g, x, y, State.CLOSED);
 193             } else {
 194             super.paintIcon(c, g, x, y);
 195             g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y + (SIZE - 3));
 196             }
 197         }
 198     }
 199 
 200     @SuppressWarnings("serial") // Superclass is not serializable across versions
 201     public class WindowsTreeCellRenderer extends DefaultTreeCellRenderer {
 202 
 203         /**
 204          * Configures the renderer based on the passed in components.
 205          * The value is set from messaging the tree with
 206          * <code>convertValueToText</code>, which ultimately invokes
 207          * <code>toString</code> on <code>value</code>.
 208          * The foreground color is set based on the selection and the icon
 209          * is set based on on leaf and expanded.
 210          */
 211         public Component getTreeCellRendererComponent(JTree tree, Object value,
 212                                                       boolean sel,
 213                                                       boolean expanded,
 214                                                       boolean leaf, int row,
 215                                                       boolean hasFocus) {
 216             super.getTreeCellRendererComponent(tree, value, sel,
 217                                                expanded, leaf, row,
 218                                                hasFocus);
 219             // Windows displays the open icon when the tree item selected.
 220             if (!tree.isEnabled()) {
 221                 setEnabled(false);
 222                 if (leaf) {
 223                     setDisabledIcon(getLeafIcon());
 224                 } else if (sel) {
 225                     setDisabledIcon(getOpenIcon());
 226                 } else {
 227                     setDisabledIcon(getClosedIcon());


 186             return new CollapsedIcon();
 187         }
 188 
 189         public void paintIcon(Component c, Graphics g, int x, int y) {
 190             Skin skin = getSkin(c);
 191             if (skin != null) {
 192                 skin.paintSkin(g, x, y, State.CLOSED);
 193             } else {
 194             super.paintIcon(c, g, x, y);
 195             g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y + (SIZE - 3));
 196             }
 197         }
 198     }
 199 
 200     @SuppressWarnings("serial") // Superclass is not serializable across versions
 201     public class WindowsTreeCellRenderer extends DefaultTreeCellRenderer {
 202 
 203         /**
 204          * Configures the renderer based on the passed in components.
 205          * The value is set from messaging the tree with
 206          * {@code convertValueToText}, which ultimately invokes
 207          * {@code toString} on {@code value}.
 208          * The foreground color is set based on the selection and the icon
 209          * is set based on on leaf and expanded.
 210          */
 211         public Component getTreeCellRendererComponent(JTree tree, Object value,
 212                                                       boolean sel,
 213                                                       boolean expanded,
 214                                                       boolean leaf, int row,
 215                                                       boolean hasFocus) {
 216             super.getTreeCellRendererComponent(tree, value, sel,
 217                                                expanded, leaf, row,
 218                                                hasFocus);
 219             // Windows displays the open icon when the tree item selected.
 220             if (!tree.isEnabled()) {
 221                 setEnabled(false);
 222                 if (leaf) {
 223                     setDisabledIcon(getLeafIcon());
 224                 } else if (sel) {
 225                     setDisabledIcon(getOpenIcon());
 226                 } else {
 227                     setDisabledIcon(getClosedIcon());
< prev index next >