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;
}
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;
}
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();
}
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);
}
}
}
});
}
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));
}
Aggregations