Skip to content
This repository has been archived by the owner on Jul 10, 2018. It is now read-only.

JTree rendering with Raven #82

Closed
nroduit opened this issue Mar 24, 2018 · 4 comments
Closed

JTree rendering with Raven #82

nroduit opened this issue Mar 24, 2018 · 4 comments

Comments

@nroduit
Copy link

nroduit commented Mar 24, 2018

Version of Substance

8.0.1

Version of Java

8_161

Version of OS

Linux

The issue you're experiencing (expected vs actual, screenshot, stack trace etc)

Try to migrate from the version 7.0.1 to 8.0.1. I've noticed some small issues with dark themes like Raven:

Version 7.0.1:
selection_013

Version 8.0.1:
selection_012

  1. The selection of an element of a JTree component is not visible.
  2. The buttons on toolbar have borders and the toolbar separator is not visible. To have flat buttons, I was using button.putClientProperty("substancelaf.componentFlat", Boolean.TRUE);
@utybo
Copy link

utybo commented Mar 24, 2018

For 2) look at SubstanceCortex..setFlatBackground

Everything you used to do with putClientProperty has been centralized in SubstanceCortex which imo is a much cleaner API.

@kirill-grouchnikov
Copy link
Owner

I'm not seeing the tree selection issue in the main Substance demo app. This maybe is a custom tree since it has checkboxes?

Can you attach a small, standalone sample app that reproduces this issue under 8.0.01 build?

As for the client properties, they have all been replaced by various scoped APIs in SubstanceCortex as pointed above. Some of them are still implemented internally by client properties, but that is an implementation detail and should not be relied on going forward.

@nroduit
Copy link
Author

nroduit commented Mar 25, 2018

Thanks for your prompt reply. For 2), I just replaced by button.putClientProperty("substancelaf.internal.FlatLook", Boolean.TRUE);

I can reproduce the issue with a simple JTree. The problem is related to DefaultTreeCellRenderer:

import javax.swing.JFrame;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;

public class TreeExample extends JFrame {

    public TreeExample() {
        try {
            UIManager.setLookAndFeel("org.pushingpixels.substance.api.skin.SubstanceRavenLookAndFeel");
        } catch (Exception e) {
            e.printStackTrace();
        }

        JTree tree = new JTree();

        DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
        DefaultMutableTreeNode vegetableNode = new DefaultMutableTreeNode("Vegetables");
        vegetableNode.add(new DefaultMutableTreeNode("Capsicum"));
        vegetableNode.add(new DefaultMutableTreeNode("Carrot"));
        vegetableNode.add(new DefaultMutableTreeNode("Tomato"));
        vegetableNode.add(new DefaultMutableTreeNode("Potato"));

        DefaultMutableTreeNode fruitNode = new DefaultMutableTreeNode("Fruits");
        fruitNode.add(new DefaultMutableTreeNode("Banana"));
        fruitNode.add(new DefaultMutableTreeNode("Mango"));
        fruitNode.add(new DefaultMutableTreeNode("Apple"));
        fruitNode.add(new DefaultMutableTreeNode("Grapes"));
        fruitNode.add(new DefaultMutableTreeNode("Orange"));

        root.add(vegetableNode);
        root.add(fruitNode);

        DefaultTreeModel model = new DefaultTreeModel(root, false);

        tree.setModel(model);
        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
        renderer.setOpenIcon(null);
        renderer.setClosedIcon(null);
        renderer.setLeafIcon(null);
        tree.setCellRenderer(renderer);

        tree.expandPath(new TreePath(vegetableNode.getPath()));
        tree.expandPath(new TreePath(fruitNode.getPath()));
        add(tree);
        
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setTitle("JTree Example");
        this.pack();
        this.setVisible(true);
    }

    public static void main(String[] args) throws Exception {
        SwingUtilities.invokeLater(TreeExample::new);
    }
}

@kirill-grouchnikov
Copy link
Owner

The tree renderer is due to "Tree.rendererFillBackground" -> false entry getting added to the UIManager defaults table. This is not needed. Will remove tonight for 8.0.02.

kirill-grouchnikov added a commit that referenced this issue Mar 26, 2018
Revert unneeded Tree.rendererFillBackground UIManager entry that interferes with core default tree cell renderers - reported in #82
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants