HighLighting JXTreeTable行

时间:2013-03-14 17:16:54

标签: java swing swingx jxtreetable swingx-highlighter

我写了下面的代码来突出显示JXTreeTable中的一行,

  public void treeExpanded(TreeExpansionEvent te) {
        final HighlightPredicate myPredicate = new HighlightPredicate() {

            @Override
            public boolean isHighlighted(Component renderer,
                    ComponentAdapter adapter) {
                double val = Double.valueOf(String.valueOf(adapter.getValueAt(1, 17)));
                return testCondition(val);
            }

            public boolean testCondition(double val) {
                if (val > 10) {
                    System.out.println("Met");

                    return true;
                } else {
                    System.out.println("NMet");

                    return false;
                }

            }
        };
        ColorHighlighter highlighter = new ColorHighlighter(myPredicate,
                Color.RED, // background color
                null);       // no change in foreground color

        table.addHighlighter(highlighter);
    }

它不起作用。请帮助

0 个答案:

没有答案