List of usage examples for javax.swing ToolTipManager sharedInstance
public static ToolTipManager sharedInstance()
ToolTipManager
instance. From source file:com.igormaznitsa.sciareto.ui.tree.ExplorerTree.java
public ExplorerTree(@Nonnull final Context context) { super();/* w w w . ja v a 2 s . co m*/ this.projectTree = new DnDTree(); this.context = context; this.projectTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); this.projectTree.setDropMode(DropMode.ON); this.projectTree.setEditable(true); ToolTipManager.sharedInstance().registerComponent(this.projectTree); this.projectTree.setCellRenderer(new TreeCellRenderer()); this.projectTree.setModel(new NodeProjectGroup(context, ".")); this.projectTree.setRootVisible(false); this.setViewportView(this.projectTree); this.projectTree.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(@Nonnull final MouseEvent e) { if (e.getClickCount() > 1) { final int selRow = projectTree.getRowForLocation(e.getX(), e.getY()); final TreePath selPath = projectTree.getPathForLocation(e.getX(), e.getY()); if (selRow >= 0) { final NodeFileOrFolder node = (NodeFileOrFolder) selPath.getLastPathComponent(); if (node != null && node.isLeaf()) { final File file = node.makeFileForNode(); if (file != null && !context.openFileAsTab(file)) { UiUtils.openInSystemViewer(file); } } } } } @Override public void mouseReleased(@Nonnull final MouseEvent e) { if (e.isPopupTrigger()) { processPopup(e); } } @Override public void mousePressed(@Nonnull final MouseEvent e) { if (e.isPopupTrigger()) { processPopup(e); } } private void processPopup(@Nonnull final MouseEvent e) { final TreePath selPath = projectTree.getPathForLocation(e.getX(), e.getY()); if (selPath != null) { projectTree.setSelectionPath(selPath); final Object last = selPath.getLastPathComponent(); if (last instanceof NodeFileOrFolder) { makePopupMenu((NodeFileOrFolder) last).show(e.getComponent(), e.getX(), e.getY()); } } } }); }
From source file:lu.lippmann.cdb.graph.GenericGraphViewImpl.java
/** * Constructor./* w w w .j av a2s . c om*/ */ @Inject public GenericGraphViewImpl() { /** initialize layout **/ final FRLayout<V, E> layout = new FRLayout<V, E>(new DirectedSparseGraph<V, E>()); //final FRLayout<V,E> layout = new FRLayout<V,E>(new GraphWithOperations()); layout.setMaxIterations(500); final VisualizationModel<V, E> vm = new DefaultVisualizationModel<V, E>(layout); this.vv = new VisualizationViewer<V, E>(vm); this.vv.setPickSupport(new ShapePickSupport<V, E>(vv, 10)); this.vv.setGraphMouse(new DefaultModalGraphMouse<V, E>()); /** Default mode */ setViewMode(ViewMode.Add); /** Gimme the time to show the rules **/ ToolTipManager.sharedInstance().setDismissDelay(50000); if (vv.getGraphMouse() instanceof CadralGraphMouse && vv.getGraphLayout().getGraph() instanceof GraphWithOperations) { //((CadralGraphMouse)vv.getGraphMouse()).setClickedGraph((GraphWithOperations)layout.getGraph()); ((CadralGraphMouse) vv.getGraphMouse()) .setClickedGraph((GraphWithOperations) vv.getGraphLayout().getGraph()); } }
From source file:ObjectInspector.java
/** * Builds a new {@link ObjectInspector}//from ww w. j a v a 2s .c om * * @param o * The object to inspect * @param showInaccessible * <code>true</code> to display inaccessible fields in * the tree, <code>false</code> to hide them * @param showStatic * <code>true</code> to show static fields, * <code>false</code> to hide them */ public ObjectInspector(Object o, boolean showInaccessible, boolean showStatic) { setModel(treeModel); showInaccessibleFields = showInaccessible; showStaticFields = showStatic; setEditable(false); addTreeWillExpandListener(expansionListener); treeRoot.refreshTree(o); ToolTipManager.sharedInstance().registerComponent(this); }
From source file:fi.smaa.jsmaa.gui.JSMAAMainFrame.java
public JSMAAMainFrame(SMAAModel model) { super(AppInfo.getAppName()); ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); ToolTipManager.sharedInstance().setInitialDelay(0); setPreferredSize(new Dimension(950, 700)); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); modelManager = new ModelFileManager(); modelManager.addPropertyChangeListener(ModelFileManager.PROPERTY_TITLE, new PropertyChangeListener() { @Override/*from www . ja va 2 s .c om*/ public void propertyChange(PropertyChangeEvent ev) { setTitle((String) ev.getNewValue()); } }); modelManager.addPropertyChangeListener(ModelFileManager.PROPERTY_MODEL, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { initWithModel((SMAAModel) evt.getNewValue()); } }); modelManager.setModel(model); }
From source file:TreeIconDemo2.java
public TreeIconDemo2() { super(new GridLayout(1, 0)); //Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series"); createNodes(top);//from ww w .jav a 2s.c om //Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); //Enable tool tips. ToolTipManager.sharedInstance().registerComponent(tree); //Set the icon for leaf nodes. ImageIcon tutorialIcon = createImageIcon("images/middle.gif"); if (tutorialIcon != null) { tree.setCellRenderer(new MyRenderer(tutorialIcon)); } else { System.err.println("Tutorial icon missing; using default."); } //Listen for when the selection changes. tree.addTreeSelectionListener(this); //Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); //Create the HTML viewing pane. htmlPane = new JEditorPane(); htmlPane.setEditable(false); initHelp(); JScrollPane htmlView = new JScrollPane(htmlPane); //Add the scroll panes to a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(htmlView); Dimension minimumSize = new Dimension(100, 50); htmlView.setMinimumSize(minimumSize); treeView.setMinimumSize(minimumSize); splitPane.setDividerLocation(100); //XXX: ignored in some releases //of Swing. bug 4101306 //workaround for bug 4101306: //treeView.setPreferredSize(new Dimension(100, 100)); splitPane.setPreferredSize(new Dimension(500, 300)); //Add the split pane to this panel. add(splitPane); }
From source file:edu.umich.robot.ViewerApplication.java
public ViewerApplication(String[] args) { JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); Config config = (args.length > 0) ? ConfigUtil.getDefaultConfig(args) : promptForConfig(); if (config == null) System.exit(1);/*from w w w . ja va 2s . com*/ setupViewerConfig(config); viewer = new Viewer(config); viewer.getVisCanvas().getViewManager().setInterfaceMode(3); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { frame.dispose(); try { Thread.sleep(500); } catch (InterruptedException ignored) { } System.exit(0); // No way to shut down april threads } }); frame.setLayout(new BorderLayout()); viewerView = new ViewerView(viewer.getVisCanvas()); // TODO SoarApril // viewer.getVisCanvas().setDrawGround(true); frame.add(viewerView, BorderLayout.CENTER); Preferences windowPrefs = getWindowPreferences(); if (windowPrefs.get("x", null) != null) { frame.setBounds(windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0), windowPrefs.getInt("width", 800), windowPrefs.getInt("height", 800)); } else { frame.setBounds(windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0), windowPrefs.getInt("width", 600), windowPrefs.getInt("height", 600)); frame.setLocationRelativeTo(null); // center } frame.getRootPane().registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent e) { frame.dispose(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); frame.pack(); frame.setVisible(true); String[] splinters = config.getStrings("splinters", new String[0]); for (String s : splinters) { addViewRobot(s); addViewLidars(s); addViewWaypoints(s); // TODO SoarApril addViewTrajectory(s); } }
From source file:com.wwidesigner.gui.StudyView.java
@Override protected void initializeComponents() { // create file tree tree = new JTree() { @Override//from w w w . j av a 2s .c o m public String getToolTipText(MouseEvent e) { String tip = null; TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path != null) { if (path.getPathCount() == 3) // it is a leaf { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); if (node instanceof TreeNodeWithToolTips) { tip = ((TreeNodeWithToolTips) node).getToolTip(); } } } return tip == null ? getToolTipText() : tip; } }; // Show tooltips for the Study view, and let them persist for 8 seconds. ToolTipManager.sharedInstance().registerComponent(tree); ToolTipManager.sharedInstance().setDismissDelay(8000); // If a Study view node doesn't fit in the pane, expand it when hovering // over it. ExpandedTipUtils.install(tree); tree.setRootVisible(false); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); tree.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path != null) { if (path.getPathCount() == 3) // it is a leaf { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent(); String category = (String) parentNode.getUserObject(); study.setCategorySelection(category, (String) node.getUserObject()); if (StudyModel.INSTRUMENT_CATEGORY_ID.equals(category) || StudyModel.TUNING_CATEGORY_ID.equals(category)) { try { study.validHoleCount(); } catch (Exception ex) { showException(ex); } } } updateView(); } } }); JScrollPane scrollPane = new JScrollPane(tree); scrollPane.setPreferredSize(new Dimension(225, 100)); add(scrollPane); Preferences myPreferences = getApplication().getPreferences(); String modelName = myPreferences.get(OptimizationPreferences.STUDY_MODEL_OPT, OptimizationPreferences.NAF_STUDY_NAME); setStudyModel(modelName); study.setPreferences(myPreferences); getApplication().getEventManager().subscribe(WIDesigner.FILE_OPENED_EVENT_ID, this); getApplication().getEventManager().subscribe(WIDesigner.FILE_CLOSED_EVENT_ID, this); getApplication().getEventManager().subscribe(WIDesigner.FILE_SAVED_EVENT_ID, this); getApplication().getEventManager().subscribe(WIDesigner.WINDOW_RENAMED_EVENT_ID, this); }
From source file:com.liveperson.infra.akka.actorx.ui.DisplayGraph.java
public static JPanel getGraphPanel() { final VisualizationViewer<String, String> vv = new VisualizationViewer<String, String>(new FRLayout(graph)); vv.setBackground(Color.white); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(vv.getPickedVertexState(), Color.blue, Color.yellow)); vv.getRenderContext().setVertexLabelTransformer(new Transformer<String, String>() { @Override/*from w w w . j a v a2s .c o m*/ public String transform(String s) { return getClassName(s); } }); vv.setVertexToolTipTransformer(new Transformer<String, String>() { @Override public String transform(String s) { return getClassName(s); } }); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<String>(vv.getPickedEdgeState(), Color.black, Color.green)); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<String, String>()); vv.setEdgeToolTipTransformer(new Transformer<String, String>() { @Override public String transform(String edge) { StringBuffer buffer = new StringBuffer(); buffer.append("<html>"); int index = edge.indexOf(Main.DELIMITER); String fromActor = edge.substring(0, index); String toActor = edge.substring(index + Main.DELIMITER.length()); Map<String, Set<String>> connections = castConnectionList.get(fromActor); Set<String> messages = connections.get(toActor); for (String msg : messages) { buffer.append("<p>").append(getClassName(msg)); } buffer.append("</html>"); return buffer.toString(); } }); ToolTipManager.sharedInstance().setDismissDelay(60000); final DefaultModalGraphMouse<String, String> graphMouse = new DefaultModalGraphMouse<String, String>(); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); vv.setGraphMouse(graphMouse); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JButton reset = new JButton("reset"); reset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Layout<String, String> layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { // if(layout instanceof IterativeContext) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); JPanel jp = new JPanel(); jp.setBackground(Color.WHITE); jp.setLayout(new BorderLayout()); jp.add(vv, BorderLayout.CENTER); Class[] combos = getCombos(); final JComboBox jcb = new JComboBox(combos); // use a renderer to shorten the layout name presentation jcb.setRenderer(new DefaultListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String valueString = value.toString(); valueString = valueString.substring(valueString.lastIndexOf('.') + 1); return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus); } }); jcb.addActionListener(new LayoutChooser(jcb, vv)); jcb.setSelectedItem(FRLayout.class); JPanel control_panel = new JPanel(new GridLayout(2, 1)); JPanel topControls = new JPanel(); JPanel bottomControls = new JPanel(); control_panel.add(topControls); control_panel.add(bottomControls); jp.add(control_panel, BorderLayout.NORTH); topControls.add(jcb); bottomControls.add(plus); bottomControls.add(minus); bottomControls.add(reset); return jp; }
From source file:com.igormaznitsa.sciareto.ui.tabs.TabTitle.java
public TabTitle(@Nonnull final Context context, @Nonnull final TabProvider parent, @Nullable final File associatedFile) { super(new GridBagLayout()); this.parent = parent; this.context = context; this.associatedFile = associatedFile; this.changed = this.associatedFile == null; this.setOpaque(false); final GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1000.0d;/* w w w .j a v a 2s . c o m*/ final TabTitle theInstance = this; this.titleLabel = new JLabel() { private static final long serialVersionUID = 8689945842487138781L; @Override protected void processKeyEvent(@Nonnull final KeyEvent e) { theInstance.getParent().dispatchEvent(e); } @Override public String getToolTipText() { return theInstance.getToolTipText(); } @Override public boolean isFocusable() { return false; } }; this.add(this.titleLabel, constraints); final Icon uiCloseIcon = UIManager.getIcon("InternalFrameTitlePane.closeIcon"); this.closeButton = new JButton(uiCloseIcon == null ? NIMBUS_CLOSE_ICON : uiCloseIcon) { private static final long serialVersionUID = -8005282815756047979L; @Override public String getToolTipText() { return theInstance.getToolTipText(); } @Override public boolean isFocusable() { return false; } }; this.closeButton.setToolTipText("Close tab"); this.closeButton.setBorder(null); this.closeButton.setContentAreaFilled(false); this.closeButton.setMargin(new Insets(0, 0, 0, 0)); this.closeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); this.closeButton.setOpaque(false); this.closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(@Nonnull final ActionEvent e) { doSafeClose(); } }); constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 0.0d; constraints.insets = new Insets(2, 8, 2, 0); this.add(this.closeButton, constraints); updateView(); ToolTipManager.sharedInstance().registerComponent(closeButton); ToolTipManager.sharedInstance().registerComponent(this.titleLabel); ToolTipManager.sharedInstance().registerComponent(this); }
From source file:de.codesourcery.eve.skills.ui.components.impl.ItemChooserComponent.java
@Override protected void onAttachHook(IComponentCallback callback) { tree.setModel(treeBuilder.getTreeModel()); ToolTipManager.sharedInstance().registerComponent(tree); }