3

The first column of JXTreeTable is not painted on hover when using the substance look and feel. The problem persists when that same column is dragged to another position as well.

Also the border is not painted as well. Is there any workaround for this?

I am using substance business l&f. I included substance swingx plugin as well.

enter image description here

Environment : Windows 7, JDK 1.6, SwingX 1.6.3, Substance 7.1

public class SwingXExample extends JFrame {
private JTabbedPane tabs = new JTabbedPane();
private JXTreeTable treeTable;
public SwingXExample() {
    JPanel treeTablePanel = new JPanel(new BorderLayout());
    treeTable = new JXTreeTable(new MyTreeTableModel());
    treeTablePanel.add(new JScrollPane(treeTable));
    tabs.addTab("JXTreeTable", treeTablePanel);
    add(tabs);
}

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                UIManager.setLookAndFeel(new SubstanceBusinessBlueSteelLookAndFeel());
            } catch (UnsupportedLookAndFeelException e) {
                e.printStackTrace();
            }
            SwingXExample frame = new SwingXExample();
            frame.setSize(400, 300);
            frame.setVisible(true);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
    });
}
}

Tree Table Model

public class MyTreeTableModel extends AbstractTreeTableModel {
    private MyTreeNode myroot;

public MyTreeTableModel() {
    myroot = new MyTreeNode("root", "Root of the tree");
    myroot.getChildren().add(
            new MyTreeNode("Empty Child 1", "This is an empty child"));

    MyTreeNode subtree = new MyTreeNode("Sub Tree",
            "This is a subtree (it has children)");
    subtree.getChildren().add(
            new MyTreeNode("EmptyChild 1, 1",
                    "This is an empty child of a subtree"));
    subtree.getChildren().add(
            new MyTreeNode("EmptyChild 1, 2",
                    "This is an empty child of a subtree"));
    myroot.getChildren().add(subtree);

    myroot.getChildren().add(
            new MyTreeNode("Empty Child 2", "This is an empty child"));
}

@Override
public int getColumnCount() {
    return 3;
}

@Override
public String getColumnName(int column) {
    switch (column) {
    case 0:
        return "Name";
    case 1:
        return "Description";
    case 2:
        return "Number Of Children";
    default:
        return "Unknown";
    }
}

@Override
public Object getValueAt(Object node, int column) {
    // System.out.println( "getValueAt: " + node + ", " + column );
    MyTreeNode treenode = (MyTreeNode) node;
    switch (column) {
    case 0:
        return treenode.getName();
    case 1:
        return treenode.getDescription();
    case 2:
        return treenode.getChildren().size();
    default:
        return "Unknown";
    }
}

@Override
public Object getChild(Object node, int index) {
    MyTreeNode treenode = (MyTreeNode) node;
    return treenode.getChildren().get(index);
}

@Override
public int getChildCount(Object parent) {
    MyTreeNode treenode = (MyTreeNode) parent;
    return treenode.getChildren().size();
}

@Override
public int getIndexOfChild(Object parent, Object child) {
    MyTreeNode treenode = (MyTreeNode) parent;
    for (int i = 0; i > treenode.getChildren().size(); i++) {
        if (treenode.getChildren().get(i) == child) {
            return i;
        }
    }
    return 0;
}

public boolean isLeaf(Object node) {
    MyTreeNode treenode = (MyTreeNode) node;
    if (treenode.getChildren().size() > 0) {
        return false;
    }
    return true;
}

@Override
public Object getRoot() {
    return myroot;
}
}
kleopatra
  • 51,061
  • 28
  • 99
  • 211
Praveen
  • 522
  • 1
  • 8
  • 17
  • interesting that highlighter doesn't work, please edit yout post with SSCCE and with informations about JDK, Native OS, SwingX version and Substance L&F too – mKorbel Jul 06 '12 at 14:53
  • thanks, unfortunatelly I'm on the swimming pool, but there are another two-three great minds – mKorbel Jul 07 '12 at 07:22
  • @kleopatra my question still is not possible ??? – mKorbel Jul 07 '12 at 08:45
  • hmm ... don't have a recent substanceLF handy on this, just guessing that the swingx plugin might not be up-to-date (though nothing changed on treetable for a while). On the other hand, it might be related to a long-standing issue on treetable which still doesn't use the table's renderers on the tree part but a special treetableCellRenderer. Plus, cell hit detection on rollover is a bit tricky, because the coordinates must be mapped to tree coordinates. Will try to give it a look next week. – kleopatra Jul 07 '12 at 10:02
  • @kleopatra you answered similair question on java.net.forum that this is not possible (lost reference... I'm on cell phone) – mKorbel Jul 07 '12 at 10:22
  • I think that JxTreeTable still uses a JTree as a cell renderer, which only works with certain look and feels. I've had good luck with Netbeans Outline, which didn't require other parts of the Netbeans Platform. See this article about why using a JTree as a cell renderer has problems. http://weblogs.java.net/blog/timboudreau/archive/2008/06/egads_an_actual.html – procrastinate_later Sep 20 '12 at 14:56
  • @procrastinate_later Thanks for the tip about Netbeans Outline. It works nicely for me. But it still has similar rendering problems with Substance that the JxTreeTable has. The highlight stripe in the table does not include the JTree portion of the display. The results look very similar to the image above. – Enwired May 14 '13 at 00:45

0 Answers0