Search in sources :

Example 16 with DefaultTreeCellRenderer

use of javax.swing.tree.DefaultTreeCellRenderer in project CodenameOne by codenameone.

the class PerformanceMonitor method refreshFrameActionPerformed.

// GEN-LAST:event_runGCActionPerformed
private void refreshFrameActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_refreshFrameActionPerformed
    componentHierarchy.setModel(new ComponentTreeModel(Display.getInstance().getCurrent()));
    componentHierarchy.setCellRenderer(new DefaultTreeCellRenderer() {

        @Override
        public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            String s = value.toString();
            if (value instanceof Component) {
                s = ((Component) value).getUIID() + ": " + s;
            }
            // To change body of generated methods, choose Tools | Templates.
            return super.getTreeCellRendererComponent(tree, s, sel, expanded, leaf, row, hasFocus);
        }
    });
    Display.getInstance().callSerially(new Runnable() {

        public void run() {
            trackDrawing = true;
            Display.getInstance().getCurrent().repaint();
            Display.getInstance().callSerially(new Runnable() {

                public void run() {
                    // data collected
                    trackDrawing = false;
                    renderedItems.setModel(createTableModel());
                }
            });
        }
    });
}
Also used : JTree(javax.swing.JTree) AttributedString(java.text.AttributedString) Component(com.codename1.ui.Component) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer)

Example 17 with DefaultTreeCellRenderer

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

the class MindMapTreeCellRenderer method getTreeCellRendererComponent.

@Override
public Component getTreeCellRendererComponent(final JTree tree, 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)

Example 18 with DefaultTreeCellRenderer

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

the class MindMapTreeCellRenderer method getTreeCellRendererComponent.

@Override
public Component getTreeCellRendererComponent(final JTree tree, 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)

Example 19 with DefaultTreeCellRenderer

use of javax.swing.tree.DefaultTreeCellRenderer in project java-swing-tips by aterai.

the class CellTextArea2 method updateUI.

@Override
public void updateUI() {
    super.updateUI();
    renderer = new DefaultTreeCellRenderer();
}
Also used : DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer)

Example 20 with DefaultTreeCellRenderer

use of javax.swing.tree.DefaultTreeCellRenderer in project checkstyle by checkstyle.

the class TreeTableCellRenderer method updateUI.

/**
 * UpdateUI is overridden to set the colors of the Tree's renderer
 * to match that of the table.
 */
@Override
public void updateUI() {
    super.updateUI();
    // Make the tree's cell renderer use the table's cell selection
    // colors.
    final TreeCellRenderer tcr = getCellRenderer();
    if (tcr instanceof DefaultTreeCellRenderer) {
        final DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tcr;
        // For 1.1 uncomment this, 1.2 has a bug that will cause an
        // exception to be thrown if the border selection color is
        // null.
        // renderer.setBorderSelectionColor(null);
        renderer.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
        renderer.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
    }
}
Also used : TreeCellRenderer(javax.swing.tree.TreeCellRenderer) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer)

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