当前位置: 首页>>代码示例>>Java>>正文


Java DefaultTreeRenderer类代码示例

本文整理汇总了Java中org.jdesktop.swingx.renderer.DefaultTreeRenderer的典型用法代码示例。如果您正苦于以下问题:Java DefaultTreeRenderer类的具体用法?Java DefaultTreeRenderer怎么用?Java DefaultTreeRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultTreeRenderer类属于org.jdesktop.swingx.renderer包,在下文中一共展示了DefaultTreeRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: interactiveXRendererCustomColor

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
/**
     * Custom renderer colors of Swingx DefaultTreeRenderer not respected.
     * (same in J/X/Tree). 
     * 
     * A bit surprising - probably due to the half-hearted support (backward
     * compatibility) of per-provider colors: they are set by the glueing
     * renderer to the provider's default visuals. Which is useless if the
     * provider is a wrapping provider - the wrappee's default visuals are unchanged.
     * 
     * PENDING JW: think about complete removal. Client code should move over
     * completely to highlighter/renderer separation anyway.
     * 
     * 
     */
    public void interactiveXRendererCustomColor() {
        JXTreeTable treeTable = new JXTreeTable(new FileSystemModel());
        treeTable.addHighlighter(HighlighterFactory.createSimpleStriping());
        DefaultTreeRenderer swingx = new DefaultTreeRenderer();
        // in a treetable this has no effect: treetable.applyRenderer 
        // internally resets them to the same colors as tree itself
        // (configured by the table's highlighters
        swingx.setBackground(Color.YELLOW);
        treeTable.setTreeCellRenderer(swingx);
        JTree tree = new JXTree(treeTable.getTreeTableModel());
        DefaultTreeRenderer other = new DefaultTreeRenderer();
        other.setBackground(Color.YELLOW);
//        other.setBackgroundSelectionColor(Color.RED);
        tree.setCellRenderer(other);
        JXFrame frame = wrapWithScrollingInFrame(treeTable, tree, "swingx renderers - highlight complete cell");
        frame.setVisible(true);  
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:32,代码来源:JXTreeTableIssues.java

示例2: interactiveTreeTableLinkRendererSimpleText

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
/**
     * Issue #??-swingx: hyperlink in JXTreeTable hierarchical column not
     * active.
     * 
     */
    public void interactiveTreeTableLinkRendererSimpleText() {
        AbstractHyperlinkAction<Object> simpleAction = new AbstractHyperlinkAction<Object>(null) {

            @Override
            public void actionPerformed(ActionEvent e) {
                LOG.info("hit: " + getTarget());
                
            }
            
        };
        JXTreeTable tree = new JXTreeTable(new FileSystemModel());
        HyperlinkProvider provider =  new HyperlinkProvider(simpleAction);
        tree.getColumn(2).setCellRenderer(new DefaultTableRenderer(provider));
        tree.setTreeCellRenderer(new DefaultTreeRenderer( //provider));
                new WrappingProvider(provider)));
//        tree.setCellRenderer(new LinkRenderer(simpleAction));
        tree.setHighlighters(HighlighterFactory.createSimpleStriping());
        JFrame frame = wrapWithScrollingInFrame(tree, "table and simple links");
        frame.setVisible(true);
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:JXTreeTableIssues.java

示例3: interactiveTreeTableGetValueRenderer

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
/**
 * Dirty example how to configure a custom renderer to use
 * treeTableModel.getValueAt(...) for showing.
 * 
 */
public void interactiveTreeTableGetValueRenderer() {
    JXTreeTable tree = new JXTreeTable(new ComponentTreeTableModel(new JXFrame()));
    ComponentProvider<?> provider = new CheckBoxProvider(StringValues.TO_STRING) {
        
        @Override
        protected String getValueAsString(CellContext context) {
            // this is dirty because the design idea was to keep the renderer 
            // unaware of the context type
            TreeTableModel model = (TreeTableModel) ((JXTree) context.getComponent()).getModel();
            // beware: currently works only if the node is not a DefaultMutableTreeNode
            // otherwise the WrappingProvider tries to be smart and replaces the node
            // by the userObject before passing on to the wrappee! 
            Object nodeValue = model.getValueAt(context.getValue(), 0);
            return formatter.getString(nodeValue);            
          }

      
    };
    tree.setTreeCellRenderer(new DefaultTreeRenderer(provider));
    tree.expandAll();
    tree.setHighlighters(HighlighterFactory.createSimpleStriping());
    JFrame frame = wrapWithScrollingInFrame(tree, "treeTable and getValueAt renderer");
    frame.setVisible(true);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:30,代码来源:JXTreeTableIssues.java

示例4: interactiveProviderIcons

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
/**  
     * use WrappingProvider: custom icons
     */    
    public void interactiveProviderIcons() {
        final JXTree tree = new JXTree(treeTableModel);
        final Icon downIcon = XTestUtils.loadDefaultIcon("wellbottom.gif");
        final Icon upIcon = XTestUtils.loadDefaultIcon("welltop.gif");
        final StringValue sv = StringValues.FILE_NAME;
        IconValue iv = new IconValue() {

            public Icon getIcon(Object value) {
                if (sv.getString(value).startsWith("A")) {
                    return downIcon;
                } else if (sv.getString(value).startsWith("D")) {
                    return upIcon;
                }
                return null;
            }
            
        };
        tree.setCellRenderer(new DefaultTreeRenderer(iv, sv));
        tree.setRowHeight(22);
        JXFrame frame = wrapWithScrollingInFrame(tree,
                "IconValue on WrappingProvider");
//        addAction(frame, toggleClosedIcon);
        frame.setVisible(true);
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:28,代码来源:JXTreeIssues.java

示例5: interactiveProviderStringValue

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
/**  
     * use WrappingProvider: default icons
     */    
    public void interactiveProviderStringValue() {
        final JXTree tree = new JXTree(treeTableModel);
        final StringValue sv = new StringValue() {

            public String getString(Object value) {
                if (value instanceof File) {
                    return ((File) value).getName();
                }
                return StringValues.TO_STRING.getString(value);
            }
            
        };
        tree.setCellRenderer(new DefaultTreeRenderer(sv));
        tree.setRowHeight(22);
        JXFrame frame = wrapWithScrollingInFrame(tree,
                "Custom StringValue on WrappingProvider, default icons");
//        addAction(frame, toggleClosedIcon);
        frame.setVisible(true);
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:23,代码来源:JXTreeIssues.java

示例6: interactiveSelectionColors

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
/**
 * Issue #862-swingx: JXTree - add api for selection colors.
 */
public void interactiveSelectionColors() {
    final JXTree tree = new JXTree();
    // use SwingX renderer which is aware of per-tree selection colors
    tree.setCellRenderer(new DefaultTreeRenderer());
    final Color uiBackground = tree.getSelectionBackground();
    final Color uiForeground = tree.getSelectionForeground();
    Action toggleSelectionColors = new AbstractAction("toggle selection colors") {
        
        public void actionPerformed(ActionEvent e) {
            if (tree.getSelectionBackground() == uiBackground) {
                tree.setSelectionBackground(Color.BLUE);
                tree.setSelectionForeground(Color.RED);
            } else {
                tree.setSelectionBackground(uiBackground);
                tree.setSelectionForeground(uiForeground);
            }
            
        }
        
    };
    JXFrame frame = wrapWithScrollingInFrame(tree, "selection color property in JXTree");
    addAction(frame, toggleSelectionColors);
    show(frame);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:28,代码来源:JXTreeVisualCheck.java

示例7: interactiveNoIconsNoUnwrap

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
/**
 * Requirements
 * - no icons, use IconValue.NONE
 * - don't unwrap user object
 */
public void interactiveNoIconsNoUnwrap() {
    TreeModel model = new ActionMapTreeTableModel(new JXTable());
    JXTree tree = new JXTree(model);
    StringValue sv = new StringValue() {

        public String getString(Object value) {
            if ((value instanceof TreeTableNode) 
                    && ((TreeTableNode) value).getColumnCount() > 0) {
                value = ((TreeTableNode) value).getValueAt(0);
            }
            return StringValues.TO_STRING.getString(value);
        }
        
    };
    DefaultTreeRenderer renderer = new DefaultTreeRenderer(IconValues.NONE, sv);
    ((WrappingProvider) renderer.getComponentProvider()).setUnwrapUserObject(false);
    tree.setCellRenderer(renderer);
    JXFrame frame = wrapWithScrollingInFrame(tree, "WrappingProvider: no icons, no unwrapped userObject");
    frame.pack();
    frame.setSize(400, 200);
    frame.setVisible(true);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:28,代码来源:JXTreeVisualCheck.java

示例8: interactiveRolloverDisabledClickTree

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
/**
 * Issue #1374-swingx: Rollover click must be disabled if target disabled
 * 
 * Visual test for JXTable, adapted from reporter's test case
 */
public void interactiveRolloverDisabledClickTree() {
    JXTree table = new JXTree();
    table.setEnabled(false);
    table.setRolloverEnabled(true);
    final JXFrame frame = showWithScrollingInFrame(table, "disable tree must not trigger rollover renderer");
    // rollover-enabled default renderer
    DefaultTreeRenderer renderer = new DefaultTreeRenderer() {
        @Override
        public void doClick() {
            JOptionPane.showMessageDialog(frame, "Click");
        }
        
        @Override
        public boolean isEnabled() {
            return true;
        }
    };
    table.setCellRenderer(renderer);
    addEnabledToggle(frame, table);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:RolloverVisualCheck.java

示例9: interactiveSelectionColors

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
/**
 * Issue #862-swingx: JXTree - add api for selection colors.
 * Here: check colors when used in JXTreeTable
 */
public void interactiveSelectionColors() {
    final JXTreeTable tree = new JXTreeTable(new FileSystemModel());
    // use SwingX renderer which is aware of per-tree selection colors
    tree.setTreeCellRenderer(new DefaultTreeRenderer());
    final Color uiBackground = tree.getSelectionBackground();
    final Color uiForeground = tree.getSelectionForeground();
    Action toggleSelectionColors = new AbstractAction("toggle selection colors") {
        
        @Override
        public void actionPerformed(ActionEvent e) {
            if (tree.getSelectionBackground() == uiBackground) {
                tree.setSelectionBackground(Color.BLUE);
                tree.setSelectionForeground(Color.RED);
            } else {
                tree.setSelectionBackground(uiBackground);
                tree.setSelectionForeground(uiForeground);
            }
            
        }
        
    };
    JXFrame frame = wrapWithScrollingInFrame(tree, "selection colors");
    addAction(frame, toggleSelectionColors);
    show(frame);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:30,代码来源:JXTreeTableVisualCheck.java

示例10: testGetStringAtHierarchicalColumn

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
/**
 * Issue #821-swingx: JXTreeTable broken string rep of hierarchical column
 * Here we test the getStringAt for the hierarchical column.
 */
@Test
public void testGetStringAtHierarchicalColumn() {
    JXTreeTable table = new JXTreeTableT(AncientSwingTeam.createNamedColorTreeTableModel());
    StringValue sv = new StringValue() {

        @Override
        public String getString(Object value) {
            if (value instanceof Color) {
                Color color = (Color) value;
                return "R/G/B: " + color.getRGB();
            }
            return StringValues.TO_STRING.getString(value);
        }
        
    };
    table.setTreeCellRenderer(new DefaultTreeRenderer(sv));
    String text = sv.getString(table.getValueAt(2, 0));
    assertTrue("sanity: text not empty", text.length() > 0);
    assertEquals(text, table.getStringAt(2, 0));
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:25,代码来源:JXTreeTableUnitTest.java

示例11: interactiveTreeLinkRendererSimpleText

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
public void interactiveTreeLinkRendererSimpleText() {
        AbstractHyperlinkAction<Object> simpleAction = new AbstractHyperlinkAction<Object>(null) {

            public void actionPerformed(ActionEvent e) {
                LOG.info("hit: " + getTarget());
                
            }
            
        };
        JXTree tree = new JXTree(new FileSystemModel());
        tree.setRolloverEnabled(true);
        HyperlinkProvider provider =  new HyperlinkProvider(simpleAction);
        tree.setCellRenderer(new DefaultTreeRenderer(provider));
//        tree.setCellRenderer(new LinkRenderer(simpleAction));
        tree.setHighlighters(HighlighterFactory.createSimpleStriping());
        JFrame frame = wrapWithScrollingInFrame(tree, "tree and simple links");
        frame.setVisible(true);
        
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:20,代码来源:JXHyperlinkVisualCheck.java

示例12: installRenderers

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
/**
 * Install renderers which use the prepared string representations.
 * Note: this method is called after the binding (aka: attach models)
 * because it installs per-column renderers which in this setup can be done only 
 * after the columns are created. 
 */
private void installRenderers() {
    initStringRepresentation();
    StringValue sv = stringValues.get("name");
    table.setDefaultRenderer(Contributor.class, new DefaultTableRenderer(sv));
    list.setCellRenderer(new DefaultListRenderer(sv));
    tree.setCellRenderer(new DefaultTreeRenderer(sv));
    treeTable.setTreeCellRenderer(new DefaultTreeRenderer(sv));
    
    for (int i = 1; i < keys.length; i++) {
        installColumnRenderers(i, new DefaultTableRenderer(stringValues.get(keys[i])));
    }
    // <snip> Unrelated, just for fun: Hyperlink 
    // Use a hyperlinkRenderer for the email column
    HyperlinkProvider provider = new HyperlinkProvider(new ContributorMailAction(
            stringValues.get("email")));
    installColumnRenderers(keys.length - 1, new DefaultTableRenderer(provider));
    table.getColumnExt(keys.length - 1).setToolTipText(
            "Note: the mail-to action will do nothing in security restricted environments");
    // </snip>
    table.packAll();
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:28,代码来源:HighlighterExtDemo.java

示例13: installRenderers

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
/**
 * Install renderers which use the prepared string representations.
 * Note: this method is called after the binding (aka: attach models)
 * because it installs per-column renderers which in this setup can be done only 
 * after the columns are created. 
 */
// <snip> Custom String Representation
// install SwingX renderers configured with the appropriate String converter
private void installRenderers() {
    StringValue sv = stringValues.get("name");
    table.setDefaultRenderer(Contributor.class, new DefaultTableRenderer(sv));
    list.setCellRenderer(new DefaultListRenderer(sv));
    tree.setCellRenderer(new DefaultTreeRenderer(sv));
    treeTable.setTreeCellRenderer(new DefaultTreeRenderer(sv));
    
    for (int i = 1; i < keys.length; i++) {
        installColumnRenderers(i, new DefaultTableRenderer(stringValues.get(keys[i])));
    }
    // </snip>
    // PENDING JW: make the email column use a hyperlinkRenderer once the
    // MatchingTextHighlighter can handle buttons
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:23,代码来源:SearchDemo.java

示例14: bindSelection

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void bindSelection(Object... components) {
    painterDemos.setCellRenderer(new DefaultTreeRenderer(
            DisplayValues.DISPLAY_INFO_DESCRIPTION)); 
    Converter<?, ?> painterConverter = new DisplayInfoConverter<Painter>();
    BindingGroup group = new BindingGroup();
    for (int i = 0; i < components.length; i++) {
        BeanProperty p = BeanProperty.create(
                i == 0 ? "backgroundPainter" : "painter");
        Binding b = Bindings.createAutoBinding(READ,
                painterDemos, BeanProperty.create("selectedElement_UNWRAP_NODE"),
                components[i], p);
        b.setConverter(painterConverter);
        group.addBinding(b);
        
    }
    group.bind();
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:19,代码来源:PainterDemo.java

示例15: SchemaTree

import org.jdesktop.swingx.renderer.DefaultTreeRenderer; //导入依赖的package包/类
@Inject
protected SchemaTree(final Datastore datastore, @Nullable final AnalysisJobBuilder analysisJobBuilder,
        final DataCleanerConfiguration configuration, final WindowContext windowContext,
        final InjectorBuilder injectorBuilder) {
    super();
    if (datastore == null) {
        throw new IllegalArgumentException("Datastore cannot be null");
    }
    _datastore = datastore;
    _windowContext = windowContext;
    _analysisJobBuilder = analysisJobBuilder;
    _configuration = configuration;
    _injectorBuilder = injectorBuilder;
    _datastoreConnection = datastore.openConnection();
    _rendererDelegate = new DefaultTreeRenderer();

    ToolTipManager.sharedInstance().registerComponent(this);

    setCellRenderer(this);
    setOpaque(false);
    setRootVisible(false);
    setRowHeight(adjuster.adjust(22));
    addTreeWillExpandListener(this);
    setDragEnabled(true);
    setTransferHandler(DragDropUtils.createSourceTransferHandler());
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:27,代码来源:SchemaTree.java


注:本文中的org.jdesktop.swingx.renderer.DefaultTreeRenderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。