Search in sources :

Example 31 with DefaultTreeCellRenderer

use of javax.swing.tree.DefaultTreeCellRenderer in project fql by CategoricalData.

the class AqlOutline method makeRenderer.

private DefaultTreeCellRenderer makeRenderer() {
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    renderer.setLeafIcon(null);
    renderer.setOpenIcon(null);
    renderer.setClosedIcon(null);
    return renderer;
}
Also used : DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer)

Example 32 with DefaultTreeCellRenderer

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

the class Designer method createNoImageTreeCellRenderer.

private TreeCellRenderer createNoImageTreeCellRenderer() {
    DefaultTreeCellRenderer treeCellRenderer = new DefaultTreeCellRenderer();
    treeCellRenderer.setLeafIcon(null);
    treeCellRenderer.setOpenIcon(null);
    treeCellRenderer.setClosedIcon(null);
    return treeCellRenderer;
}
Also used : DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer)

Example 33 with DefaultTreeCellRenderer

use of javax.swing.tree.DefaultTreeCellRenderer in project airavata by apache.

the class ComponentSelector method initGUI.

private void initGUI() {
    this.treeModel = new ComponentTreeModel(new ComponentTreeNode("Components"));
    this.tree = new JTree(this.treeModel);
    // Add a tool tip.
    ToolTipManager.sharedInstance().registerComponent(this.tree);
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() {

        @Override
        public java.awt.Component getTreeCellRendererComponent(JTree t, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean focus) {
            super.getTreeCellRendererComponent(t, value, sel, expanded, leaf, row, focus);
            ComponentTreeNode node = (ComponentTreeNode) value;
            if (node.getComponentReference() == null) {
                setToolTipText(null);
            } else {
                setToolTipText("Drag a component to the composer to add");
            }
            return this;
        }
    };
    // Change icons
    try {
        renderer.setOpenIcon(SwingUtil.createImageIcon("opened.gif"));
        renderer.setClosedIcon(SwingUtil.createImageIcon("closed.gif"));
        renderer.setLeafIcon(SwingUtil.createImageIcon("leaf.gif"));
    } catch (RuntimeException e) {
        logger.warn("Failed to load image icons.  " + "It will use the default icons instead.", e);
    }
    this.tree.setCellRenderer(renderer);
    this.tree.setShowsRootHandles(true);
    this.tree.setEditable(false);
    this.tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    this.tree.addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent event) {
            // update.
            if (event.isAddedPath()) {
                TreePath path = event.getPath();
                select(path);
            }
        }
    });
    // Drag and dtop
    DragGestureListener dragGestureListener = new DragGestureListener() {

        public void dragGestureRecognized(DragGestureEvent event) {
            ComponentSelector.this.dragGestureRecognized(event);
        }
    };
    DragSource dragSource = DragSource.getDefaultDragSource();
    dragSource.createDefaultDragGestureRecognizer(this.tree, DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    this.dragSourceListener = new DragSourceAdapter() {
    };
    // Popup
    this.tree.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent event) {
            if (event.isPopupTrigger()) {
                showPopupIfNecessary(event);
            }
        }
    });
    createNodePopupMenu();
}
Also used : DragSourceAdapter(java.awt.dnd.DragSourceAdapter) MouseEvent(java.awt.event.MouseEvent) DragGestureEvent(java.awt.dnd.DragGestureEvent) DragGestureListener(java.awt.dnd.DragGestureListener) MouseAdapter(java.awt.event.MouseAdapter) TreeSelectionListener(javax.swing.event.TreeSelectionListener) DragSource(java.awt.dnd.DragSource) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) JTree(javax.swing.JTree) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) TreePath(javax.swing.tree.TreePath) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 34 with DefaultTreeCellRenderer

use of javax.swing.tree.DefaultTreeCellRenderer in project android-classyshark by google.

the class FilesTree method configureJTree.

private void configureJTree(final JTree jTree) {
    jTree.setRootVisible(false);
    DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) jTree.getCellRenderer();
    cellRenderer.setFont(new Font("Monospaced", Font.PLAIN, 20));
    jTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            Object selection = jTree.getLastSelectedPathComponent();
            if (selection == null)
                return;
            DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) selection;
            if (selection.toString().endsWith(".dex")) {
                FilesTree.this.viewerController.onSelectedClassName((String) defaultMutableTreeNode.getUserObject());
                return;
            }
            if (selection.toString().endsWith(".jar")) {
                FilesTree.this.viewerController.onSelectedClassName((String) defaultMutableTreeNode.getUserObject());
                return;
            }
            if (selection.toString().endsWith(".apk")) {
                FilesTree.this.viewerController.onSelectedClassName((String) defaultMutableTreeNode.getUserObject());
                return;
            }
            if (selection.toString().endsWith(".so")) {
                FilesTree.this.viewerController.onSelectedClassName((String) defaultMutableTreeNode.getUserObject());
                return;
            }
            if (!defaultMutableTreeNode.isLeaf())
                return;
            if (FilesTree.this.viewerController != null) {
                if (defaultMutableTreeNode.getUserObject() instanceof String) {
                    FilesTree.this.viewerController.onSelectedClassName((String) defaultMutableTreeNode.getUserObject());
                } else {
                    FilesTree.this.viewerController.onSelectedClassName(((NodeInfo) defaultMutableTreeNode.getUserObject()).fullname);
                }
            }
        }
    });
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeSelectionListener(javax.swing.event.TreeSelectionListener) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) Font(java.awt.Font)

Example 35 with DefaultTreeCellRenderer

use of javax.swing.tree.DefaultTreeCellRenderer in project android-classyshark by google.

the class MethodsCountPanel method setup.

private void setup() {
    this.setLayout(new BorderLayout());
    treeModel = new DefaultTreeModel(new DefaultMutableTreeNode(null));
    jTree = new JTree(treeModel);
    jTree.setRootVisible(false);
    jTree.setCellRenderer(new CellRenderer());
    theme.applyTo(jTree);
    DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) jTree.getCellRenderer();
    cellRenderer.setFont(new Font("Monospaced", Font.PLAIN, 20));
    jTree.setCellRenderer(cellRenderer);
    jTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            Object selection = jTree.getLastSelectedPathComponent();
            DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) selection;
            ClassNode node = (ClassNode) defaultMutableTreeNode.getUserObject();
            viewerController.onSelectedMethodCount(node);
        }
    });
    JScrollPane jScrollPane = new JScrollPane(jTree);
    this.setBorder(new EmptyBorder(0, 0, 0, 0));
    this.add(jScrollPane, BorderLayout.CENTER);
    theme.applyTo(jScrollPane);
    jTree.setDragEnabled(true);
    jTree.setTransferHandler(new FileTransferHandler(viewerController));
}
Also used : JScrollPane(javax.swing.JScrollPane) ClassNode(com.google.classyshark.silverghost.methodscounter.ClassNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CellRenderer(com.google.classyshark.gui.panel.tree.CellRenderer) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) TreeSelectionListener(javax.swing.event.TreeSelectionListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) FileTransferHandler(com.google.classyshark.gui.panel.FileTransferHandler) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) Font(java.awt.Font) JTree(javax.swing.JTree) BorderLayout(java.awt.BorderLayout) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) EmptyBorder(javax.swing.border.EmptyBorder)

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