Example usage for javax.swing ToolTipManager sharedInstance

List of usage examples for javax.swing ToolTipManager sharedInstance

Introduction

In this page you can find the example usage for javax.swing ToolTipManager sharedInstance.

Prototype

public static ToolTipManager sharedInstance() 

Source Link

Document

Returns a shared ToolTipManager instance.

Usage

From source file:Main.java

void start() {
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.setInitialDelay(0);//from w  ww . j a  v  a  2 s  .  c  o m
    ttm.setDismissDelay(10000);

    Main newContentPane = new Main();
    newContentPane.setOpaque(true);

    JFrame frame = new JFrame("Main");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(newContentPane);
    frame.pack();
    frame.setLocation(150, 150);
    frame.setVisible(true);
}

From source file:Main.java

public Main() throws HeadlessException {
    setSize(300, 300);//  w  w w  .  ja v  a  2s  .  c  o  m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));

    JButton disable = new JButton("DISABLE");
    disable.setToolTipText("disabled.");
    disable.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ToolTipManager.sharedInstance().setEnabled(false);
        }
    });
    JButton enable = new JButton("ENABLE");
    enable.setToolTipText("enabled.");
    enable.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ToolTipManager.sharedInstance().setEnabled(true);
        }
    });
    getContentPane().add(enable);
    getContentPane().add(disable);
}

From source file:Main.java

public Main(Properties props) {
    model = new SortedListModel();
    setModel(model);/*from w w w .j  a v a2  s. c o  m*/
    ToolTipManager.sharedInstance().registerComponent(this);

    tipProps = props;
    addProperties(props);
}

From source file:MainClass.java

public MainClass(Properties props) {
    model = new SortedListModel();
    setModel(model);/*from w  ww.  ja v  a 2  s  .  com*/
    ToolTipManager.sharedInstance().registerComponent(this);

    tipProps = props;
    addProperties(props);
}

From source file:Main.java

public PropertiesList(Properties props) {
    model = new SortedListModel();
    setModel(model);//w w  w . j a v  a  2s  . com
    ToolTipManager.sharedInstance().registerComponent(this);

    tipProps = props;
    addProperties(props);
}

From source file:org.argouml.application.Main.java

/**
 * The main entry point of ArgoUML.//from   www.  java2 s .co m
 * @param args command line parameters
 */
public static void main(String[] args) {
    try {
        LOG.info("ArgoUML Started.");

        SimpleTimer st = new SimpleTimer();
        st.mark("begin");

        initPreinitialize();

        st.mark("arguments");
        parseCommandLine(args);

        // Register our last chance exception handler
        AwtExceptionHandler.registerExceptionHandler();

        // Get the splash screen up as early as possible
        st.mark("create splash");
        SplashScreen splash = null;
        if (!batch) {
            // We have to do this to set the LAF for the splash screen
            st.mark("initialize laf");
            LookAndFeelMgr.getInstance().initializeLookAndFeel();
            if (theTheme != null) {
                LookAndFeelMgr.getInstance().setCurrentTheme(theTheme);
            }
            if (doSplash) {
                splash = initializeSplash();
            }
        }

        // main initialization happens here
        ProjectBrowser pb = initializeSubsystems(st, splash);

        // Needs to happen after initialization is done & modules loaded
        st.mark("perform commands");
        if (batch) {
            // TODO: Add an "open most recent project" command so that 
            // command state can be decoupled from user settings?
            performCommandsInternal(commands);
            commands = null;

            System.out.println("Exiting because we are running in batch.");
            new ActionExit().doCommand(null);
            return;
        }

        if (reloadRecent && projectName == null) {
            projectName = getMostRecentProject();
        }

        URL urlToOpen = null;
        if (projectName != null) {
            projectName = PersistenceManager.getInstance().fixExtension(projectName);
            urlToOpen = projectUrl(projectName, urlToOpen);
        }

        openProject(st, splash, pb, urlToOpen);

        st.mark("perspectives");
        if (splash != null) {
            splash.updateProgress(75);
        }

        st.mark("open window");
        updateProgress(splash, 95, "statusmsg.bar.open-project-browser");
        ArgoFrame.getFrame().setVisible(true);

        st.mark("close splash");
        if (splash != null) {
            splash.setVisible(false);
            splash.dispose();
            splash = null;
        }

        // Aufrufen der Aufgabenstellung
        if (taskID != null) {
            ActionShowTask task = new ActionShowTask();
            task.showTask();
            if (projectName == null && ActionShowTask.taskDescription != null
                    && (ActionShowTask.taskDescription.toLowerCase().contains("aktivittsdiagramm")
                            || ActionShowTask.taskDescription.toLowerCase().contains("aktivitts-diagramm")
                            || ActionShowTask.taskDescription.toLowerCase().contains("aktivitätsdiagramm")
                            || ActionShowTask.taskDescription.toLowerCase().contains("aktivitäts-diagramm")
                            || ActionShowTask.taskDescription.toLowerCase().contains("activity diagram")
                            || ActionShowTask.taskDescription.toLowerCase().contains("activity-diagram"))) {
                new ActionActivityDiagram().actionPerformed(null);
            }
        }

        performCommands(commands);
        commands = null;

        st.mark("start critics");
        Runnable startCritics = new StartCritics();
        Main.addPostLoadAction(startCritics);

        st.mark("start loading modules");
        Runnable moduleLoader = new LoadModules();
        Main.addPostLoadAction(moduleLoader);

        PostLoad pl = new PostLoad(postLoadActions);
        Thread postLoadThead = new Thread(pl);
        postLoadThead.start();

        LOG.info("");
        LOG.info("profile of load time ############");
        for (Enumeration i = st.result(); i.hasMoreElements();) {
            LOG.info(i.nextElement());
        }
        LOG.info("#################################");
        LOG.info("");

        st = null;
        ArgoFrame.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

        // Andreas: just temporary: a warning dialog for uml2...
        if (showUml2warning && Model.getFacade().getUmlVersion().startsWith("2")) {
            JOptionPane.showMessageDialog(ArgoFrame.getFrame(),
                    "You are running an experimental version not meant for productive work!",
                    "UML2 pre-alpha warning", JOptionPane.WARNING_MESSAGE);
        }

        //ToolTipManager.sharedInstance().setInitialDelay(500);
        ToolTipManager.sharedInstance().setDismissDelay(50000000);
    } catch (Throwable t) {
        try {
            LOG.fatal("Fatal error on startup.  ArgoUML failed to start", t);
        } finally {
            System.out.println("Fatal error on startup.  " + "ArgoUML failed to start.");
            t.printStackTrace();
            System.exit(1);
        }
    }
}

From source file:hr.fer.zemris.vhdllab.platform.support.VhdllabLifecycleAdvisor.java

@Override
public void onPreStartup() {
    new UserLocaleInitializer().initLocale();
    ToolTipManager.sharedInstance().setDismissDelay(15000); // 15 seconds
}

From source file:FileTree3.java

public FileTree3() {
    super("Directories Tree [Tool Tips]");
    setSize(400, 300);/*from   w  w  w  .  j a v  a2s  .c om*/

    DefaultMutableTreeNode top = new DefaultMutableTreeNode(new IconData(ICON_COMPUTER, null, "Computer"));

    DefaultMutableTreeNode node;
    File[] roots = File.listRoots();
    for (int k = 0; k < roots.length; k++) {
        node = new DefaultMutableTreeNode(new IconData(ICON_DISK, null, new FileNode(roots[k])));
        top.add(node);
        node.add(new DefaultMutableTreeNode(new Boolean(true)));
    }

    m_model = new DefaultTreeModel(top);
    // NEW
    m_tree = new JTree(m_model) {
        public String getToolTipText(MouseEvent ev) {
            if (ev == null)
                return null;
            TreePath path = m_tree.getPathForLocation(ev.getX(), ev.getY());
            if (path != null) {
                FileNode fnode = getFileNode(getTreeNode(path));
                if (fnode == null)
                    return null;
                File f = fnode.getFile();
                return (f == null ? null : f.getPath());
            }
            return null;
        }
    };
    ToolTipManager.sharedInstance().registerComponent(m_tree);

    m_tree.putClientProperty("JTree.lineStyle", "Angled");

    TreeCellRenderer renderer = new IconCellRenderer();
    m_tree.setCellRenderer(renderer);

    m_tree.addTreeExpansionListener(new DirExpansionListener());

    m_tree.addTreeSelectionListener(new DirSelectionListener());

    m_tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    m_tree.setShowsRootHandles(true);
    m_tree.setEditable(false);

    JScrollPane s = new JScrollPane();
    s.getViewport().add(m_tree);
    getContentPane().add(s, BorderLayout.CENTER);

    m_display = new JTextField();
    m_display.setEditable(false);
    getContentPane().add(m_display, BorderLayout.NORTH);

    m_popup = new JPopupMenu();
    m_action = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (m_clickedPath == null)
                return;
            if (m_tree.isExpanded(m_clickedPath))
                m_tree.collapsePath(m_clickedPath);
            else
                m_tree.expandPath(m_clickedPath);
        }
    };
    m_popup.add(m_action);
    m_popup.addSeparator();

    Action a1 = new AbstractAction("Delete") {
        public void actionPerformed(ActionEvent e) {
            m_tree.repaint();
            JOptionPane.showMessageDialog(FileTree3.this, "Delete option is not implemented", "Info",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    };
    m_popup.add(a1);

    Action a2 = new AbstractAction("Rename") {
        public void actionPerformed(ActionEvent e) {
            m_tree.repaint();
            JOptionPane.showMessageDialog(FileTree3.this, "Rename option is not implemented", "Info",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    };
    m_popup.add(a2);
    m_tree.add(m_popup);
    m_tree.addMouseListener(new PopupTrigger());

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    setVisible(true);
}

From source file:gtu._work.etc.HotnoteMakerUI.java

private void initGUI() {
    try {/*from  w  w  w  .  j  a  v a 2s.com*/
        ToolTipManager.sharedInstance().setInitialDelay(0);
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("hott notes - checklist", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(612, 348));
                    {
                        checkListArea = new JTextArea();
                        jScrollPane1.setViewportView(checkListArea);
                        checkListArea.addMouseListener(new MouseAdapter() {

                            String randomColor() {
                                StringBuilder sb = new StringBuilder().append("#");
                                for (int ii = 0; ii < 6; ii++) {
                                    sb.append(RandomUtil.randomChar('a', 'b', 'c', 'd', 'f', '0', '1', '2', '3',
                                            '4', '5', '6', '7', '8', '9'));
                                }
                                return sb.toString();
                            }

                            void saveXml(Document document, File file) {
                                OutputFormat format = OutputFormat.createPrettyPrint();
                                format.setEncoding("utf-16");
                                XMLWriter writer = null;
                                try {
                                    writer = new XMLWriter(new FileWriter(file), format);
                                    writer.write(document);
                                } catch (IOException e) {
                                    JCommonUtil.handleException(e);
                                } finally {
                                    if (writer != null) {
                                        try {
                                            writer.close();
                                        } catch (IOException e) {
                                            JCommonUtil.handleException(e);
                                        }
                                    }
                                }
                            }

                            public void mouseClicked(MouseEvent evt) {
                                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                                    return;
                                }

                                if (StringUtils.isEmpty(checkListArea.getText())) {
                                    JCommonUtil
                                            ._jOptionPane_showMessageDialog_error("checklist area is empty!");
                                    return;
                                }

                                File file = JCommonUtil._jFileChooser_selectFileOnly_saveFile();
                                if (file == null) {
                                    JCommonUtil._jOptionPane_showMessageDialog_error("file is not correct!");
                                    return;
                                }

                                //XXX
                                StringTokenizer tok = new StringTokenizer(checkListArea.getText(), "\t\n\r\f");
                                List<String> list = new ArrayList<String>();
                                String tmp = null;
                                for (; tok.hasMoreElements();) {
                                    tmp = ((String) tok.nextElement()).trim();
                                    System.out.println(tmp);
                                    list.add(tmp);
                                }
                                //XXX

                                Document document = DocumentHelper.createDocument();
                                Element rootHot = document.addElement("hottnote");
                                rootHot.addAttribute("creationtime",
                                        new Timestamp(System.currentTimeMillis()).toString());
                                rootHot.addAttribute("lastmodified",
                                        new Timestamp(System.currentTimeMillis()).toString());
                                rootHot.addAttribute("type", "checklist");
                                //appearence
                                Element appearenceE = rootHot.addElement("appearence");
                                appearenceE.addAttribute("alpha", "204");
                                Element fontE = appearenceE.addElement("font");
                                fontE.addAttribute("face", "Default");
                                fontE.addAttribute("size", "0");
                                Element styleE = appearenceE.addElement("style");
                                styleE.addElement("bg2color").addAttribute("color", randomColor());
                                styleE.addElement("bgcolor").addAttribute("color", randomColor());
                                styleE.addElement("textcolor").addAttribute("color", randomColor());
                                styleE.addElement("titlecolor").addAttribute("color", randomColor());
                                //behavior
                                rootHot.addElement("behavior");
                                //content
                                Element contentE = rootHot.addElement("content");
                                Element checklistE = contentE.addElement("checklist");
                                for (String val : list) {
                                    checklistE.addElement("item").addCDATA(val);
                                }
                                //desktop
                                Element desktopE = rootHot.addElement("desktop");
                                desktopE.addElement("position").addAttribute("x", RandomUtil.numberStr(3))
                                        .addAttribute("y", RandomUtil.numberStr(3));
                                desktopE.addElement("size").addAttribute("height", "200").addAttribute("width",
                                        "200");
                                //title
                                Element titleE = rootHot.addElement("title");
                                titleE.addCDATA(StringUtils.defaultIfEmpty(checkListTitle.getText(),
                                        DateFormatUtils.format(System.currentTimeMillis(), "dd/MM/yyyy")));

                                if (!file.getName().toLowerCase().endsWith(".hottnote")) {
                                    file = new File(file.getParentFile(), file.getName() + ".hottnote");
                                }

                                saveXml(document, file);
                                JCommonUtil._jOptionPane_showMessageDialog_info("completed!\n" + file);
                            }
                        });
                    }
                }
                {
                    checkListTitle = new JTextField();
                    checkListTitle.setToolTipText("title");
                    jPanel1.add(checkListTitle, BorderLayout.NORTH);
                }
            }
        }
        pack();
        this.setSize(633, 415);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

From source file:dotaSoundEditor.Controls.ItemPanel.java

public ItemPanel(String _vpkPath, String _installDir, CacheManager _cm, SoundPlayer _sp) {
    vpkPath = _vpkPath;/* w  ww .jav a 2s .  c om*/
    installDir = _installDir;
    this.setName("Items");
    initComponents();

    soundPlayer = _sp;
    cacheManager = _cm;
    currentTree = itemTree;
    portraitFinder = Utility.portraitFinder;
    this.populateSoundList();
    initTreeSelectionListener();
    fillImageFrame("default");
    ToolTipManager.sharedInstance().setDismissDelay(20000);
    ToolTipManager.sharedInstance().setInitialDelay(0);
}