Search in sources :

Example 36 with DefaultTreeCellRenderer

use of javax.swing.tree.DefaultTreeCellRenderer in project netbeans-mmd-plugin by raydac.

the class MindMapTreeCellRenderer method getTreeCellRendererComponent.

@Override
@Nonnull
public Component getTreeCellRendererComponent(@Nonnull final JTree tree, @Nonnull final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
    final DefaultTreeCellRenderer result = (DefaultTreeCellRenderer) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    if (value instanceof Topic) {
        result.setIcon(getIconForTopic((Topic) value));
        result.setText(extractTextFromTopic((Topic) value));
    }
    return result;
}
Also used : Topic(com.igormaznitsa.mindmap.model.Topic) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) Nonnull(javax.annotation.Nonnull)

Aggregations

DefaultTreeCellRenderer (javax.swing.tree.DefaultTreeCellRenderer)36 JTree (javax.swing.JTree)13 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)13 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)12 TreePath (javax.swing.tree.TreePath)10 MouseAdapter (java.awt.event.MouseAdapter)7 MouseEvent (java.awt.event.MouseEvent)7 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)7 TreeCellRenderer (javax.swing.tree.TreeCellRenderer)7 Dimension (java.awt.Dimension)4 JLabel (javax.swing.JLabel)4 JPanel (javax.swing.JPanel)4 JScrollPane (javax.swing.JScrollPane)4 TreeSelectionListener (javax.swing.event.TreeSelectionListener)4 Topic (com.igormaznitsa.mindmap.model.Topic)3 BorderLayout (java.awt.BorderLayout)3 Component (java.awt.Component)3 ActionEvent (java.awt.event.ActionEvent)3 KeyAdapter (java.awt.event.KeyAdapter)3 KeyEvent (java.awt.event.KeyEvent)3