List of usage examples for javax.swing ToolTipManager sharedInstance
public static ToolTipManager sharedInstance()
ToolTipManager
instance. From source file:edu.umich.robot.GuiApplication.java
/** * Entry point./*ww w .j a va 2s .c o m*/ * * @param args Args from command line. */ public GuiApplication(Config config) { // Heavyweight is not desirable but it is the only thing that will // render in front of the Viewer on all platforms. Blame OpenGL JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); // must have config //Config config = (args.length > 0) ? ConfigUtil.getDefaultConfig(args) : promptForConfig(frame); if (config == null) System.exit(1); // Add more stuff to the config file that doesn't change between runs. Application.setupSimulatorConfig(config); setupViewerConfig(config); Configs.toLog(logger, config); controller = new Controller(config, new Gamepad()); controller.initializeGamepad(); viewer = new Viewer(config, frame); // This puts us in full 3d mode by default. The Viewer GUI doesn't // reflect this in its right click drop-down, a bug. viewer.getVisCanvas().getViewManager().setInterfaceMode(3); controller.addListener(RobotAddedEvent.class, listener); controller.addListener(RobotRemovedEvent.class, listener); controller.addListener(AfterResetEvent.class, listener); controller.addListener(ControllerActivatedEvent.class, listener); controller.addListener(ControllerDeactivatedEvent.class, listener); actionManager = new ActionManager(this); initActions(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { controller.shutdown(); System.exit(0); } }); frame.setLayout(new BorderLayout()); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.add(actionManager.getAction(CreateSplinterRobotAction.class)); fileMenu.add(actionManager.getAction(CreateSuperdroidRobotAction.class)); fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(ConnectSuperdroidAction.class)); fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(ResetPreferencesAction.class)); /* fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(TextMessageAction.class)); */ fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(SaveMapAction.class)); fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(ExitAction.class)); menuBar.add(fileMenu); JMenu cameraMenu = new JMenu("Camera"); cameraMenu.add(actionManager.getAction(DisableFollowAction.class)); cameraMenu.add(actionManager.getAction(FollowPositionAction.class)); cameraMenu.add(actionManager.getAction(FollowPositionAndThetaAction.class)); cameraMenu.add(new JSeparator()); cameraMenu.add(actionManager.getAction(MoveCameraBehindAction.class)); cameraMenu.add(actionManager.getAction(MoveCameraAboveAction.class)); menuBar.add(cameraMenu); JMenu objectMenu = new JMenu("Objects"); boolean added = false; for (String objectName : controller.getObjectNames()) { added = true; objectMenu.add(new AddObjectAction(this, objectName)); } if (!added) objectMenu.add(new JLabel("No objects available")); menuBar.add(objectMenu); menuBar.revalidate(); frame.setJMenuBar(menuBar); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); toolBar.add(actionManager.getAction(SoarParametersAction.class)); toolBar.add(actionManager.getAction(SoarDataAction.class)); toolBar.add(actionManager.getAction(ResetAction.class)); toolBar.add(actionManager.getAction(SoarToggleAction.class)); toolBar.add(actionManager.getAction(SoarStepAction.class)); toolBar.add(actionManager.getAction(SimSpeedAction.class)); frame.add(toolBar, BorderLayout.PAGE_START); viewerView = new ViewerView(viewer.getVisCanvas()); robotsView = new RobotsView(this, actionManager); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, viewerView, robotsView); splitPane.setDividerLocation(0.75); // TODO SoarApril /* viewer.addRobotSelectionChangedListener(robotsView); viewer.getVisCanvas().setDrawGround(true); */ viewer.getVisCanvas().addEventHandler(new VisCanvasEventAdapter() { public String getName() { return "Place Object"; } @Override public boolean mouseClicked(VisCanvas vc, GRay3D ray, MouseEvent e) { boolean ret = false; synchronized (GuiApplication.this) { if (objectToAdd != null && controller != null) { controller.addObject(objectToAdd, ray.intersectPlaneXY()); objectToAdd = null; ret = true; } else { double[] click = ray.intersectPlaneXY(); chatView.setClick(new Point2D.Double(click[0], click[1])); } } status.setMessage( String.format("%3.1f,%3.1f", ray.intersectPlaneXY()[0], ray.intersectPlaneXY()[1])); return ret; } }); consoleView = new ConsoleView(); chatView = new ChatView(this); controller.getRadio().addRadioHandler(chatView); final JSplitPane bottomPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, consoleView, chatView); bottomPane.setDividerLocation(200); final JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, splitPane, bottomPane); splitPane2.setDividerLocation(0.75); frame.add(splitPane2, BorderLayout.CENTER); status = new StatusBar(); frame.add(status, BorderLayout.SOUTH); /* frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { final Preferences windowPrefs = getWindowPreferences(); final Rectangle r = frame.getBounds(); if(frame.getExtendedState() == JFrame.NORMAL) { windowPrefs.putInt("x", r.x); windowPrefs.putInt("y", r.y); windowPrefs.putInt("width", r.width); windowPrefs.putInt("height", r.height); windowPrefs.putInt("divider", splitPane.getDividerLocation()); } exit(); }}); Preferences windowPrefs = getWindowPreferences(); if (windowPrefs.get("x", null) != null) { frame.setBounds( windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0), windowPrefs.getInt("width", 1200), windowPrefs.getInt("height", 900)); splitPane.setDividerLocation(windowPrefs.getInt("divider", 500)); } else { frame.setBounds( windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0), windowPrefs.getInt("width", 1200), windowPrefs.getInt("height", 900)); splitPane.setDividerLocation(0.75); frame.setLocationRelativeTo(null); // center } */ frame.getRootPane().setBounds(0, 0, 1600, 1200); 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); for (String s : config.getStrings("splinters", new String[0])) { double[] pos = config.getDoubles(s + ".position"); if (pos == null) { logger.error("Splinter indexed in config file but no position defined: " + s); continue; } Pose pose = new Pose(pos); String prods = config.getString(s + ".productions"); boolean collisions = config.getBoolean(s + ".wallCollisions", true); controller.createSplinterRobot(s, pose, collisions); boolean simulated = config.getBoolean(s + ".simulated", true); if (simulated) controller.createSimSplinter(s); else controller.createRealSplinter(s); controller.createSimLaser(s); if (prods != null) { controller.createSoarController(s, s, prods, config.getChild(s + ".properties")); PREFERENCES.put("lastProductions", prods); } } for (String s : config.getStrings("superdroids", new String[0])) { double[] pos = config.getDoubles(s + ".position"); if (pos == null) { logger.error("Superdroid indexed in config file but no position defined: " + s); continue; } Pose pose = new Pose(pos); String prods = config.getString(s + ".productions"); boolean collisions = config.getBoolean(s + ".wallCollisions", true); controller.createSuperdroidRobot(s, pose, collisions); boolean simulated = config.getBoolean(s + ".simulated", true); if (simulated) controller.createSimSuperdroid(s); else { try { controller.createRealSuperdroid(s, "192.168.1.165", 3192); } catch (UnknownHostException e1) { e1.printStackTrace(); } catch (SocketException e1) { e1.printStackTrace(); } } controller.createSimLaser(s); if (prods != null) { // wait a sec try { Thread.sleep(1000); } catch (InterruptedException ex) { } controller.createSoarController(s, s, prods, config.getChild(s + ".properties")); PREFERENCES.put("lastProductions", prods); } } }
From source file:com.haulmont.cuba.desktop.App.java
protected void initUI() { ToolTipManager.sharedInstance().setEnabled(false); mainFrame = createMainFrame();/* w ww. j ava 2s.co m*/ mainFrame.setName("MainFrame"); mainFrame.addWindowListener(new ValidationAwareWindowClosingListener() { @Override public void windowClosingAfterValidation(WindowEvent e) { exit(); } }); mainFrame.setContentPane(createStartContentPane()); registerFrame(mainFrame); createMainWindowProperties().load(); }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatConversationPanel.java
/** * Creates an instance of <tt>ChatConversationPanel</tt>. * * @param chatContainer The parent <tt>ChatConversationContainer</tt>. *//*from w w w .j a v a2 s . com*/ public ChatConversationPanel(ChatConversationContainer chatContainer) { editorKit = new ChatConversationEditorKit(this); this.chatContainer = chatContainer; isHistory = (chatContainer instanceof HistoryWindow); this.rightButtonMenu = new ChatRightButtonMenu(this); this.document = (HTMLDocument) editorKit.createDefaultDocument(); this.document.addDocumentListener(editorKit); this.chatTextPane.setEditorKitForContentType("text/html", editorKit); this.chatTextPane.setEditorKit(editorKit); this.chatTextPane.setEditable(false); this.chatTextPane.setDocument(document); this.chatTextPane.setDragEnabled(true); chatTextPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); Constants.loadSimpleStyle(document.getStyleSheet(), chatTextPane.getFont()); this.chatTextPane.addHyperlinkListener(this); this.chatTextPane.addMouseListener(this); this.chatTextPane.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); this.addChatLinkClickedListener(showPreview); this.setWheelScrollingEnabled(true); this.setViewportView(chatTextPane); this.setBorder(null); this.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); ToolTipManager.sharedInstance().registerComponent(chatTextPane); String copyLinkString = GuiActivator.getResources().getI18NString("service.gui.COPY_LINK"); copyLinkItem = new JMenuItem(copyLinkString, new ImageIcon(ImageLoader.getImage(ImageLoader.COPY_ICON))); copyLinkItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { StringSelection stringSelection = new StringSelection(currentHref); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, ChatConversationPanel.this); } }); String openLinkString = GuiActivator.getResources().getI18NString("service.gui.OPEN_IN_BROWSER"); openLinkItem = new JMenuItem(openLinkString, new ImageIcon(ImageLoader.getImage(ImageLoader.BROWSER_ICON))); openLinkItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { GuiActivator.getBrowserLauncher().openURL(currentHref); // after opening the link remove the currentHref to avoid // clicking on the window to gain focus to open the link again ChatConversationPanel.this.currentHref = ""; } }); openLinkItem.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OPEN_IN_BROWSER")); copyLinkItem.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.COPY_LINK")); configureReplacementItem = new JMenuItem( GuiActivator.getResources().getI18NString("plugin.chatconfig.replacement.CONFIGURE_REPLACEMENT"), GuiActivator.getResources().getImage("service.gui.icons.CONFIGURE_ICON")); configureReplacementItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final ConfigurationContainer configContainer = GuiActivator.getUIService() .getConfigurationContainer(); ConfigurationForm chatConfigForm = getChatConfigForm(); if (chatConfigForm != null) { configContainer.setSelected(chatConfigForm); configContainer.setVisible(true); } } }); this.isSimpleTheme = ConfigurationUtils.isChatSimpleThemeEnabled(); /* * When we append a new message (regardless of whether it is a string or * an UI component), we want to make it visible in the viewport of this * JScrollPane so that the user can see it. */ ComponentListener componentListener = new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { synchronized (scrollToBottomRunnable) { if (!scrollToBottomIsPending) return; scrollToBottomIsPending = false; /* * Yana Stamcheva, pointed out that Java 5 (on Linux only?) * needs invokeLater for JScrollBar. */ SwingUtilities.invokeLater(scrollToBottomRunnable); } } }; chatTextPane.addComponentListener(componentListener); getViewport().addComponentListener(componentListener); }
From source file:com.eviware.soapui.SoapUI.java
private void buildUI() { // display used java version log.info("Used java version: " + System.getProperty("java.version")); frame.addWindowListener(new MainFrameWindowListener()); UISupport.setMainFrame(frame);/* ww w .j av a 2s .c o m*/ navigator = new Navigator(workspace); navigator.addNavigatorListener(new InternalNavigatorListener()); desktopPanelsList = new JDesktopPanelsList(desktop); mainInspector = JInspectorPanelFactory.build(buildContentPanel(), SwingConstants.LEFT); mainInspector.addInspector( new JComponentInspector<JComponent>(buildMainPanel(), "Navigator", "The soapUI Navigator", true)); mainInspector.setCurrentInspector("Navigator"); frame.setJMenuBar(buildMainMenu()); frame.getContentPane().add(buildToolbar(), BorderLayout.NORTH); frame.getContentPane().add(mainInspector.getComponent(), BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setSize(1000, 750); mainInspector.setDividerLocation(250); mainInspector.setResizeWeight(0.1); navigator.selectModelItem(workspace); desktop.addDesktopListener(internalDesktopListener); ToolTipManager.sharedInstance().setInitialDelay(200); JTree mainTree = navigator.getMainTree(); DragSource dragSource = DragSource.getDefaultDragSource(); SoapUIDragAndDropHandler navigatorDragAndDropHandler = new SoapUIDragAndDropHandler( new NavigatorDragAndDropable(mainTree), DropType.ON + DropType.AFTER); dragSource.createDefaultDragGestureRecognizer(mainTree, DnDConstants.ACTION_COPY_OR_MOVE, navigatorDragAndDropHandler); desktop.init(); }
From source file:com.anrisoftware.prefdialog.core.AbstractFieldComponent.java
private void showToolTip() { int id = 0;/*w w w. j av a 2 s . c o m*/ long when = 0; int modifiers = 0; int x = 0; int y = 0; int clickCount = 0; ToolTipManager.sharedInstance() .mouseMoved(new MouseEvent(component, id, when, modifiers, x, y, clickCount, false)); }
From source file:com.anrisoftware.prefdialog.core.AbstractFieldComponent.java
private void hideToolTip() { int id = 0;//from w w w. jav a 2s .c om long when = 0; int modifiers = 0; int x = 0; int y = 0; int clickCount = 0; ToolTipManager.sharedInstance() .mouseExited(new MouseEvent(component, id, when, modifiers, x, y, clickCount, false)); }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Switches chart tooltip generation on or off. * * @param flag the flag.//w w w. ja va 2 s.c o m */ public void setDisplayToolTips(boolean flag) { if (flag) { ToolTipManager.sharedInstance().registerComponent(this); } else { ToolTipManager.sharedInstance().unregisterComponent(this); } }
From source file:de.codesourcery.planning.swing.PlanningCanvas.java
@Override public void addNotify() { super.addNotify(); ToolTipManager.sharedInstance().registerComponent(this); }
From source file:de.codesourcery.planning.swing.PlanningCanvas.java
@Override public void removeNotify() { super.removeNotify(); ToolTipManager.sharedInstance().unregisterComponent(this); }
From source file:net.pms.newgui.LooksFrame.java
/** * Constructs a <code>DemoFrame</code>, configures the UI, * and builds the content./*w w w . j a va 2 s . co m*/ */ public LooksFrame(AutoUpdater autoUpdater, @Nonnull PmsConfiguration configuration, @Nonnull WindowPropertiesConfiguration windowConfiguration) { super(windowConfiguration.getGraphicsConfiguration()); if (configuration == null) { throw new IllegalArgumentException("configuration can't be null"); } setResizable(true); windowProperties = new WindowProperties(this, STANDARD_SIZE, MINIMUM_SIZE, windowConfiguration); this.autoUpdater = autoUpdater; this.configuration = configuration; assert this.configuration != null; setMinimumSize(MINIMUM_SIZE); Options.setDefaultIconSize(new Dimension(18, 18)); Options.setUseNarrowButtons(true); // Set view level, can be omitted if ViewLevel is implemented in configuration // by setting the view level as variable initialization if (configuration.isHideAdvancedOptions()) { viewLevel = ViewLevel.NORMAL; } else { viewLevel = ViewLevel.ADVANCED; } // Global options Options.setTabIconsEnabled(true); UIManager.put(Options.POPUP_DROP_SHADOW_ENABLED_KEY, null); // Swing Settings initializeLookAndFeel(); // wait till the look and feel has been initialized before (possibly) displaying the update notification dialog if (autoUpdater != null) { autoUpdater.addObserver(this); autoUpdater.pollServer(); } // Shared Fonts final Integer twelve = Integer.valueOf(12); final Integer fontPlain = Integer.valueOf(Font.PLAIN); final Integer fontBold = Integer.valueOf(Font.BOLD); LazyValue dialogPlain12 = new LazyValue() { @Override public Object createValue(UIDefaults t) { return new FontUIResource(Font.DIALOG, fontPlain, twelve); } }; LazyValue sansSerifPlain12 = new LazyValue() { @Override public Object createValue(UIDefaults t) { return new FontUIResource(Font.SANS_SERIF, fontPlain, twelve); } }; LazyValue monospacedPlain12 = new LazyValue() { @Override public Object createValue(UIDefaults t) { return new FontUIResource(Font.MONOSPACED, fontPlain, twelve); } }; LazyValue dialogBold12 = new LazyValue() { @Override public Object createValue(UIDefaults t) { return new FontUIResource(Font.DIALOG, fontBold, twelve); } }; Object MenuFont = dialogPlain12; Object FixedControlFont = monospacedPlain12; Object ControlFont = dialogPlain12; Object MessageFont = dialogPlain12; Object WindowFont = dialogBold12; Object ToolTipFont = sansSerifPlain12; Object IconFont = ControlFont; // Override our fonts with a unicode font for languages with special characters final String language = configuration.getLanguageTag(); if (language != null && (language.equals("ja") || language.startsWith("zh") || language.equals("ko"))) { // http://propedit.sourceforge.jp/propertieseditor.jnlp MenuFont = sansSerifPlain12; FixedControlFont = sansSerifPlain12; ControlFont = sansSerifPlain12; MessageFont = sansSerifPlain12; WindowFont = sansSerifPlain12; IconFont = sansSerifPlain12; } UIManager.put("Button.font", ControlFont); UIManager.put("CheckBox.font", ControlFont); UIManager.put("CheckBoxMenuItem.font", MenuFont); UIManager.put("ComboBox.font", ControlFont); UIManager.put("EditorPane.font", ControlFont); UIManager.put("FileChooser.listFont", IconFont); UIManager.put("FormattedTextField.font", ControlFont); UIManager.put("InternalFrame.titleFont", WindowFont); UIManager.put("Label.font", ControlFont); UIManager.put("List.font", ControlFont); UIManager.put("PopupMenu.font", MenuFont); UIManager.put("Menu.font", MenuFont); UIManager.put("MenuBar.font", MenuFont); UIManager.put("MenuItem.font", MenuFont); UIManager.put("MenuItem.acceleratorFont", MenuFont); UIManager.put("RadioButton.font", ControlFont); UIManager.put("RadioButtonMenuItem.font", MenuFont); UIManager.put("OptionPane.font", MessageFont); UIManager.put("OptionPane.messageFont", MessageFont); UIManager.put("OptionPane.buttonFont", MessageFont); UIManager.put("Panel.font", ControlFont); UIManager.put("PasswordField.font", ControlFont); UIManager.put("ProgressBar.font", ControlFont); UIManager.put("ScrollPane.font", ControlFont); UIManager.put("Slider.font", ControlFont); UIManager.put("Spinner.font", ControlFont); UIManager.put("TabbedPane.font", ControlFont); UIManager.put("Table.font", ControlFont); UIManager.put("TableHeader.font", ControlFont); UIManager.put("TextArea.font", FixedControlFont); UIManager.put("TextField.font", ControlFont); UIManager.put("TextPane.font", ControlFont); UIManager.put("TitledBorder.font", ControlFont); UIManager.put("ToggleButton.font", ControlFont); UIManager.put("ToolBar.font", MenuFont); UIManager.put("ToolTip.font", ToolTipFont); UIManager.put("Tree.font", ControlFont); UIManager.put("Viewport.font", ControlFont); setTitle("Test"); setIconImage(readImageIcon("icon-32.png").getImage()); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JComponent jp = buildContent(); String showScrollbars = System.getProperty("scrollbars", "").toLowerCase(); /** * Handle scrollbars: * * 1) forced scrollbars (-Dscrollbars=true): always display them * 2) optional scrollbars (-Dscrollbars=optional): display them as needed * 3) otherwise (default): don't display them */ switch (showScrollbars) { case "true": setContentPane(new JScrollPane(jp, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS)); break; case "optional": setContentPane(new JScrollPane(jp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED)); break; default: setContentPane(jp); break; } String projectName = PropertiesUtil.getProjectProperties().get("project.name"); String projectVersion = PropertiesUtil.getProjectProperties().get("project.version"); String title = projectName + " " + projectVersion; // If the version contains a "-" (e.g. "1.50.1-SNAPSHOT" or "1.50.1-beta1"), add a warning message if (projectVersion.indexOf('-') > -1) { title = title + " - " + Messages.getString("LooksFrame.26"); } if (PMS.getTraceMode() == 2) { // Forced trace mode title = title + " [" + Messages.getString("TracesTab.10").toUpperCase() + "]"; } setTitle(title); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); // Display tooltips immediately and for a long time ToolTipManager.sharedInstance().setInitialDelay(400); ToolTipManager.sharedInstance().setDismissDelay(60000); ToolTipManager.sharedInstance().setReshowDelay(400); if (!configuration.isMinimized() && System.getProperty(START_SERVICE) == null) { setVisible(true); } BasicSystemUtils.INSTANCE.addSystemTray(this); }