Java Code Examples for javax.swing.JTree#setToolTipText()
The following examples show how to use
javax.swing.JTree#setToolTipText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSONTree.java From rest-client with Apache License 2.0 | 6 votes |
/** * * @Title : JSONTree * @Description: Default constructor * @Param : */ public JSONTree() { super(new GridLayout(1, 0)); rootNode = new CheckBoxTreeNode(RESTConst.JSON); treeModel = new DefaultTreeModel(rootNode); tree = new JTree(treeModel); tree.setCellRenderer(new CheckBoxTreeCellRenderer()); tree.setEditable(false); tree.setToolTipText(RESTConst.EXCLUDE_NODE); tree.setShowsRootHandles(true); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.addMouseListener(ma); JScrollPane scrollPane = new JScrollPane(tree); this.add(scrollPane); this.initPopupMenu(); }
Example 2
Source File: TreeCellRenderer.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
@Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; if (CatalogTreeUtils.isDapNode(value)) { setLeafIcon(dapIcon); setToolTip(node, tree); } else if (CatalogTreeUtils.isFileNode(value)) { setLeafIcon(fileIcon); setToolTip(node, tree); } else try { if (leaf && isOpendapLeaf(node) && CatalogTreeUtils.getCatalogDatasets(node).isEmpty()) { setLeafIcon(errorIcon); tree.setToolTipText(null); } else { setLeafIcon(getClosedIcon()); } } catch (IOException e) { setLeafIcon(errorIcon); tree.setToolTipText(null); } super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); return this; }
Example 3
Source File: CatalogTreeUtils.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
public static void addCellRenderer(final JTree jTree) { final ImageIcon dapIcon = UIUtils.loadImageIcon("/org/esa/snap/opendap/images/icons/DRsProduct16.png", CatalogTree.class); final ImageIcon fileIcon = UIUtils.loadImageIcon("/org/esa/snap/opendap/images/icons/FRsProduct16.png", CatalogTree.class); final ImageIcon errorIcon = UIUtils.loadImageIcon("/org/esa/snap/opendap/images/icons/NoAccess16.png", CatalogTree.class); jTree.setToolTipText(null); jTree.setCellRenderer(new TreeCellRenderer(dapIcon, fileIcon, errorIcon)); }
Example 4
Source File: WindowsDirectoryChooserUI.java From orbit-image-analysis with GNU General Public License v3.0 | 4 votes |
public void installComponents(JFileChooser chooser) { this.chooser = (JDirectoryChooser)chooser; chooser.setLayout(LookAndFeelTweaks.createBorderLayout()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); Component accessory = chooser.getAccessory(); if (accessory != null) { chooser.add("North", chooser.getAccessory()); } tree = new JTree() { public String getToolTipText(MouseEvent event) { String tip = WindowsDirectoryChooserUI.this.getToolTipText(event); if (tip == null) { return super.getToolTipText(event); } else { return tip; } } }; tree.addTreeExpansionListener(new TreeExpansion()); tree.setModel(new FileSystemTreeModel(chooser.getFileSystemView())); tree.setRootVisible(false); tree.setShowsRootHandles(false); tree.setCellRenderer(new FileSystemTreeRenderer()); tree.setToolTipText(""); chooser.add("Center", treeScroll = new JScrollPane(tree)); treeScroll.setPreferredSize(new Dimension(300, 300)); approveButton = new JButton(); approveButton.setAction(getApproveSelectionAction()); cancelButton = new JButton(); cancelButton.addActionListener(getCancelSelectionAction()); buttonPanel = new JPanel(LookAndFeelTweaks.createButtonAreaLayout()); buttonPanel.add(approveButton); buttonPanel.add(cancelButton); chooser.add("South", buttonPanel); updateView(chooser); }
Example 5
Source File: TreeCellRenderer.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private void setToolTip(DefaultMutableTreeNode value, JTree tree) { int fileSize = ((OpendapLeaf) value.getUserObject()).getFileSize(); tree.setToolTipText(OpendapUtils.format(fileSize / 1024.0) + " MB"); }