JXTreeTable物质L& F涂料问题

时间:2012-07-06 13:19:42

标签: java swing swingx substance jxtreetable

使用物质外观时,JXTreeTable的第一列在悬停时不会被绘制。当同一列也被拖动到另一个位置时,问题仍然存在。

边框也没有画过。有没有解决方法呢?

我正在使用物质业务l& f。我还包括物质swingx插件。

enter image description here

环境:Windows 7,JDK 1.6,SwingX 1.6.3,物质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);
        }
    });
}
}

树表模型

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

0 个答案:

没有答案