Coder Social home page Coder Social logo

JTree rendering with Raven about substance HOT 4 CLOSED

nroduit avatar nroduit commented on June 16, 2024
JTree rendering with Raven

from substance.

Comments (4)

utybo avatar utybo commented on June 16, 2024

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.

from substance.

kirill-grouchnikov avatar kirill-grouchnikov commented on June 16, 2024

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.

from substance.

nroduit avatar nroduit commented on June 16, 2024

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);
    }
}

from substance.

kirill-grouchnikov avatar kirill-grouchnikov commented on June 16, 2024

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.

from substance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.