Example usage for javax.swing JButton setToolTipText

List of usage examples for javax.swing JButton setToolTipText

Introduction

In this page you can find the example usage for javax.swing JButton setToolTipText.

Prototype

@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
public void setToolTipText(String text) 

Source Link

Document

Registers the text to display in a tool tip.

Usage

From source file:de.ipk_gatersleben.ag_nw.graffiti.services.GUIhelper.java

public static JComponent getWebsiteDownloadButton(final String title, final String optUrlManualDownloadWebsite,
        final String target_dir_null_ask_user, final String optIntroText, final String[] downloadURLs,
        final String optIntroDialogTitle, final FileDownloadStatusInformationProvider statusProvider,
        final Runnable optFinishSwingTask) {

    final JButton res = new JMButton("Download/Update");
    res.setToolTipText(
            "<html>Click button to start automatic download<br><code><b>Check License/Disclaimers first!");
    res.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            final String opt_local_folder;
            if (target_dir_null_ask_user == null) {
                File file = OpenFileDialogService.getDirectoryFromUser("Select folder");
                if (file == null)
                    return;
                else
                    opt_local_folder = file.getAbsolutePath();
            } else {
                opt_local_folder = target_dir_null_ask_user;
            }// ww w .ja  v  a 2s.c o  m

            res.setEnabled(false);
            res.setText("Downloading");
            final BackgroundTaskStatusProviderSupportingExternalCallImpl status = new BackgroundTaskStatusProviderSupportingExternalCallImpl(
                    "Please wait...", "Downloading files...");
            BackgroundTaskHelper.issueSimpleTask(title, "Please wait...", new Runnable() {
                public void run() {
                    boolean allOK = true;
                    for (String downloadURL : downloadURLs) {
                        allOK = performDownload(downloadURL, opt_local_folder, status);
                        if (status.wantsToStop()) {
                            break;
                        }
                    }
                    if (status.wantsToStop()) {
                        allOK = true;
                        try {
                            status.setCurrentStatusText1("Cancel...");
                            for (String downloadURL : downloadURLs) {
                                String fileName = downloadURL.substring(downloadURL.lastIndexOf("/") + 1);
                                if (downloadURL.contains("|"))
                                    fileName = downloadURL.substring(downloadURL.lastIndexOf("|") + 1);
                                String targetFileName = ReleaseInfo.getAppFolderWithFinalSep() + fileName;
                                if (new File(targetFileName).exists()) {
                                    new File(targetFileName).delete();
                                    status.setCurrentStatusText2("Delete " + targetFileName);
                                }
                            }
                        } catch (Exception e) {
                            //
                        }
                    }

                    if (!allOK) {
                        res.setEnabled(true);
                        res.setText(
                                "<html><small>Automatic download failure<br>Click here for manual download");
                        res.removeActionListener(res.getActionListeners()[0]);
                        res.addActionListener(getDialogAction(optUrlManualDownloadWebsite, opt_local_folder,
                                optIntroText, optIntroDialogTitle));
                        res.requestFocus();
                        final JDialog jd = (JDialog) ErrorMsg.findParentComponent(res, JDialog.class);
                        if (jd != null) {
                            SwingUtilities.invokeLater(new Runnable() {
                                public void run() {
                                    jd.pack();
                                }
                            });
                        }
                    } else {
                        if (status.wantsToStop()) {
                            res.setText("Canceled");
                            status.pleaseContinueRun();
                            status.setCurrentStatusText2("Canceled!");
                        } else {
                            res.setText("Downloaded");
                        }
                        res.setEnabled(false);
                        if (statusProvider != null)
                            statusProvider.finishedNewDownload();
                        if (optFinishSwingTask != null)
                            SwingUtilities.invokeLater(optFinishSwingTask);
                    }
                }
            }, null, status);
        }
    });
    return res;
}

From source file:ColoredToolTipExample.java

public ColoredToolTipExample() {
    super("Colored ToolTip Example");

    UIManager.put("ToolTip.foreground", new ColorUIResource(Color.red));
    UIManager.put("ToolTip.background", new ColorUIResource(Color.yellow));

    JButton button = new JButton("Hello, world");
    button.setToolTipText("Red / Yellow");
    getContentPane().add(button);//from  ww  w.j  a  v  a 2  s . c  o m
}

From source file:Main.java

public Main() throws HeadlessException {
    setSize(300, 300);//from   w w  w. j av  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:MyLookAndFeel.java

public Main() throws Exception {
    UIManager.setLookAndFeel("MyLookAndFeel");
    setLayout(new FlowLayout());

    JButton b = new JButton();
    b.setText("<html>A<br> B</html>");
    b.setToolTipText("<html>C<br>D<br>E</html>");

    add(b);/*from  w w  w.  ja va  2  s . c  o  m*/

    JLabel l = new JLabel("Z");
    l.setToolTipText("zzzzz...");

    add(l);
}

From source file:MainClass.java

MainClass(String title) {
    super(title);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JToolBar toolBar = new JToolBar();
    Action a = new AbstractAction("Demo") {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Action taken.");
        }// w  ww  .ja v a 2s. c om
    };

    JButton b = toolBar.add(a);
    b.setText("Demo Button");
    b.setToolTipText("Press me to take action.");

    JMenu mainMenu = new JMenu("Menu");
    JMenuItem mi = mainMenu.add(a);
    mi.getAccessibleContext().setAccessibleName("Menu item");

    JMenuBar mb = new JMenuBar();
    mb.add(mainMenu);
    setJMenuBar(mb);

    JPanel pane = new JPanel();
    pane.setLayout(new BorderLayout());
    pane.setPreferredSize(new Dimension(200, 100));
    pane.add(toolBar, BorderLayout.NORTH);
    setContentPane(pane);

    pack();
    setVisible(true);
}

From source file:ButtonScroll.java

protected JButton createButton(String name, char mnemonics) {
    JButton btn = new JButton(name);
    btn.setToolTipText("Move " + name);
    btn.setBorderPainted(false);//from   w  ww  .j  a  v  a2 s . c o  m
    btn.setMargin(new Insets(0, 0, 0, 0));
    btn.setContentAreaFilled(false);
    btn.setMnemonic(mnemonics);
    return btn;
}

From source file:org.uncommons.watchmaker.swing.evolutionmonitor.JVMView.java

/**
 * Creates the GUI controls for toggling graph display options.
 * @return A component that can be added to the main panel.
 *///from   w  w  w  .  j av  a2s .  c o  m
private JComponent createControls() {
    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton gcButton = new JButton("Request GC");
    gcButton.setToolTipText("Perform garbage collection (the JVM may ignore this request).");
    gcButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            memoryBean.gc();
        }
    });
    controls.add(gcButton);
    return controls;
}

From source file:net.sf.jabref.gui.help.HelpAction.java

public JButton getHelpButton() {
    JButton button = new JButton(this);
    button.setText(null);/*from   ww  w .  j a  v a  2s. c  om*/
    button.setPreferredSize(new Dimension(24, 24));
    button.setToolTipText(getValue(Action.SHORT_DESCRIPTION).toString());
    return button;
}

From source file:components.ToolBarDemo.java

protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText,
        String altText) {/*from   w w  w.  jav a 2s.  co  m*/
    //Look for the image.
    String imgLocation = "images/" + imageName + ".gif";
    URL imageURL = ToolBarDemo.class.getResource(imgLocation);

    //Create and initialize the button.
    JButton button = new JButton();
    button.setActionCommand(actionCommand);
    button.setToolTipText(toolTipText);
    button.addActionListener(this);

    if (imageURL != null) { //image found
        button.setIcon(new ImageIcon(imageURL, altText));
    } else { //no image found
        button.setText(altText);
        System.err.println("Resource not found: " + imgLocation);
    }

    return button;
}

From source file:SwingToolBarDemo.java

protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText,
        String altText) {/*  ww w .  j ava  2 s  . co m*/
    //Look for the image.
    String imgLocation = "toolbarButtonGraphics/navigation/" + imageName + ".gif";
    URL imageURL = SwingToolBarDemo.class.getResource(imgLocation);

    //Create and initialize the button.
    JButton button = new JButton();
    button.setActionCommand(actionCommand);
    button.setToolTipText(toolTipText);
    button.addActionListener(this);

    if (imageURL != null) { //image found
        button.setIcon(new ImageIcon(imageURL, altText));
    } else { //no image found
        button.setText(altText);
        System.err.println("Resource not found: " + imgLocation);
    }

    return button;
}