Example usage for javax.swing JTabbedPane setToolTipTextAt

List of usage examples for javax.swing JTabbedPane setToolTipTextAt

Introduction

In this page you can find the example usage for javax.swing JTabbedPane setToolTipTextAt.

Prototype

@BeanProperty(preferred = true, description = "The tooltip text at the specified tab index.")
public void setToolTipTextAt(int index, String toolTipText) 

Source Link

Document

Sets the tooltip text at index to toolTipText which can be null.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    String label = "Tab Label";
    String tooltip = "Tool Tip Text";
    pane.addTab(label, null, new JButton("Button"), tooltip);
    int index = pane.getTabCount() - 1;
    tooltip = pane.getToolTipTextAt(index);
    tooltip = "New Tool Tip Text";
    pane.setToolTipTextAt(index, tooltip);

}

From source file:de.dal33t.powerfolder.ui.information.stats.StatsInformationCard.java

/**
 * Build the ui component pane./*from   w ww .  ja v a  2  s  . c o m*/
 */
private void buildUIComponent() {

    FormLayout layout = new FormLayout("3dlu, fill:pref:grow, 3dlu", "3dlu, fill:pref:grow, 3dlu");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    CellConstraints cc = new CellConstraints();
    JTabbedPane tabbedPane = new JTabbedPane();

    builder.add(tabbedPane, cc.xy(2, 2));

    JPanel usedPanel = getUsedPanel();
    tabbedPane.add(usedPanel, Translation.getTranslation("stats_information_card.used_graph.text"));
    tabbedPane.setToolTipTextAt(0, Translation.getTranslation("stats_information_card.used_graph.tip"));

    JPanel averagePanel = getAveragePanel();
    tabbedPane.add(averagePanel, Translation.getTranslation("stats_information_card.percentage_graph.text"));
    tabbedPane.setToolTipTextAt(1, Translation.getTranslation("stats_information_card.percentage_graph.tip"));

    uiComponent = builder.getPanel();
}

From source file:BorderDemo.java

public BorderDemo() {
    super(new GridLayout(1, 0));

    // Keep references to the next few borders,
    // for use in titles and compound borders.
    Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty;

    // A border that puts 10 extra pixels at the sides and
    // bottom of each pane.
    Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10);

    blackline = BorderFactory.createLineBorder(Color.black);
    raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    raisedbevel = BorderFactory.createRaisedBevelBorder();
    loweredbevel = BorderFactory.createLoweredBevelBorder();
    empty = BorderFactory.createEmptyBorder();

    // First pane: simple borders
    JPanel simpleBorders = new JPanel();
    simpleBorders.setBorder(paneEdge);/*from  w  ww.j  av  a2 s.  c o  m*/
    simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS));

    addCompForBorder(blackline, "line border", simpleBorders);
    addCompForBorder(raisedetched, "raised etched border", simpleBorders);
    addCompForBorder(loweredetched, "lowered etched border", simpleBorders);
    addCompForBorder(raisedbevel, "raised bevel border", simpleBorders);
    addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders);
    addCompForBorder(empty, "empty border", simpleBorders);

    // Second pane: matte borders
    JPanel matteBorders = new JPanel();
    matteBorders.setBorder(paneEdge);
    matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS));

    ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); // 20x22
    Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,<null-icon>)", matteBorders);
    }
    border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red);
    addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders);

    border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (0,20,0,0,<null-icon>)", matteBorders);
    }

    // Third pane: titled borders
    JPanel titledBorders = new JPanel();
    titledBorders.setBorder(paneEdge);
    titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS));
    TitledBorder titled;

    titled = BorderFactory.createTitledBorder("title");
    addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders);

    titled = BorderFactory.createTitledBorder(blackline, "title");
    addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredetched, "title");
    addCompForTitledBorder(titled, "titled lowered etched border" + " (right just., default pos.)",
            TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredbevel, "title");
    addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders);

    titled = BorderFactory.createTitledBorder(empty, "title");
    addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders);

    // Fourth pane: compound borders
    JPanel compoundBorders = new JPanel();
    compoundBorders.setBorder(paneEdge);
    compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS));
    Border redline = BorderFactory.createLineBorder(Color.red);

    Border compound;
    compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);
    addCompForBorder(compound, "compound border (two bevels)", compoundBorders);

    compound = BorderFactory.createCompoundBorder(redline, compound);
    addCompForBorder(compound, "compound border (add a red outline)", compoundBorders);

    titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER,
            TitledBorder.BELOW_BOTTOM);
    addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Simple", null, simpleBorders, null);
    tabbedPane.addTab("Matte", null, matteBorders, null);
    tabbedPane.addTab("Titled", null, titledBorders, null);
    tabbedPane.addTab("Compound", null, compoundBorders, null);
    tabbedPane.setSelectedIndex(0);
    String toolTip = new String(
            "<html>Blue Wavy Line border art crew:<br>&nbsp;&nbsp;&nbsp;Bill Pauley<br>&nbsp;&nbsp;&nbsp;Cris St. Aubyn<br>&nbsp;&nbsp;&nbsp;Ben Wronsky<br>&nbsp;&nbsp;&nbsp;Nathan Walrath<br>&nbsp;&nbsp;&nbsp;Tommy Adams, special consultant</html>");
    tabbedPane.setToolTipTextAt(1, toolTip);

    add(tabbedPane);
}

From source file:components.BorderDemo.java

public BorderDemo() {
    super(new GridLayout(1, 0));

    //Keep references to the next few borders,
    //for use in titles and compound borders.
    Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty;

    //A border that puts 10 extra pixels at the sides and
    //bottom of each pane.
    Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10);

    blackline = BorderFactory.createLineBorder(Color.black);
    raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    raisedbevel = BorderFactory.createRaisedBevelBorder();
    loweredbevel = BorderFactory.createLoweredBevelBorder();
    empty = BorderFactory.createEmptyBorder();

    //First pane: simple borders
    JPanel simpleBorders = new JPanel();
    simpleBorders.setBorder(paneEdge);//from  w ww .  ja va2  s.  com
    simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS));

    addCompForBorder(blackline, "line border", simpleBorders);
    addCompForBorder(raisedetched, "raised etched border", simpleBorders);
    addCompForBorder(loweredetched, "lowered etched border", simpleBorders);
    addCompForBorder(raisedbevel, "raised bevel border", simpleBorders);
    addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders);
    addCompForBorder(empty, "empty border", simpleBorders);

    //Second pane: matte borders
    JPanel matteBorders = new JPanel();
    matteBorders.setBorder(paneEdge);
    matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS));

    ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); //20x22
    Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,<null-icon>)", matteBorders);
    }
    border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red);
    addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders);

    border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (0,20,0,0,<null-icon>)", matteBorders);
    }

    //Third pane: titled borders
    JPanel titledBorders = new JPanel();
    titledBorders.setBorder(paneEdge);
    titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS));
    TitledBorder titled;

    titled = BorderFactory.createTitledBorder("title");
    addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders);

    titled = BorderFactory.createTitledBorder(blackline, "title");
    addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredetched, "title");
    addCompForTitledBorder(titled, "titled lowered etched border" + " (right just., default pos.)",
            TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredbevel, "title");
    addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders);

    titled = BorderFactory.createTitledBorder(empty, "title");
    addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders);

    //Fourth pane: compound borders
    JPanel compoundBorders = new JPanel();
    compoundBorders.setBorder(paneEdge);
    compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS));
    Border redline = BorderFactory.createLineBorder(Color.red);

    Border compound;
    compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);
    addCompForBorder(compound, "compound border (two bevels)", compoundBorders);

    compound = BorderFactory.createCompoundBorder(redline, compound);
    addCompForBorder(compound, "compound border (add a red outline)", compoundBorders);

    titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER,
            TitledBorder.BELOW_BOTTOM);
    addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Simple", null, simpleBorders, null);
    tabbedPane.addTab("Matte", null, matteBorders, null);
    tabbedPane.addTab("Titled", null, titledBorders, null);
    tabbedPane.addTab("Compound", null, compoundBorders, null);
    tabbedPane.setSelectedIndex(0);
    String toolTip = new String(
            "<html>Blue Wavy Line border art crew:<br>&nbsp;&nbsp;&nbsp;Bill Pauley<br>&nbsp;&nbsp;&nbsp;Cris St. Aubyn<br>&nbsp;&nbsp;&nbsp;Ben Wronsky<br>&nbsp;&nbsp;&nbsp;Nathan Walrath<br>&nbsp;&nbsp;&nbsp;Tommy Adams, special consultant</html>");
    tabbedPane.setToolTipTextAt(1, toolTip);

    add(tabbedPane);
}

From source file:org.springframework.richclient.factory.DefaultComponentFactory.java

public void addConfiguredTab(JTabbedPane tabbedPane, String labelKey, JComponent tabComponent) {
    org.springframework.richclient.core.LabelInfo info = getLabelInfo(getRequiredMessage(labelKey));
    tabbedPane.addTab(info.getText(), tabComponent);
    int tabIndex = tabbedPane.getTabCount() - 1;
    tabbedPane.setMnemonicAt(tabIndex, info.getMnemonic());
    tabbedPane.setDisplayedMnemonicIndexAt(tabIndex, info.getMnemonicIndex());
    tabbedPane.setIconAt(tabIndex, getIcon(labelKey));
    tabbedPane.setToolTipTextAt(tabIndex, getCaption(labelKey));
}

From source file:pcgen.gui2.dialog.AboutDialog.java

/**
 * Construct the credits panel. This panel shows basic details
 * about PCGen and lists all involved in it's creation.
 *
 * @return The credits panel.//w  ww  .j av a2  s  .  c om
 */
private JPanel buildCreditsPanel() {

    JLabel versionLabel = new JLabel();
    JLabel dateLabel = new JLabel();
    JLabel javaVersionLabel = new JLabel();
    JLabel leaderLabel = new JLabel();
    JLabel helperLabel = new JLabel();
    JLabel wwwLink = new JLabel();
    JLabel emailLabel = new JLabel();
    JTextField version = new JTextField();
    JTextField releaseDate = new JTextField();
    JTextField javaVersion = new JTextField();
    JTextField projectLead = new JTextField();
    wwwSite = new JButton();
    mailingList = new JButton();
    JTabbedPane monkeyTabPane = new JTabbedPane();

    JPanel aCreditsPanel = new JPanel();
    aCreditsPanel.setLayout(new GridBagLayout());

    // Labels

    versionLabel.setText(LanguageBundle.getString("in_abt_version")); //$NON-NLS-1$
    GridBagConstraints gridBagConstraints1 = buildConstraints(0, 0, GridBagConstraints.WEST);
    gridBagConstraints1.weightx = 0.2;
    aCreditsPanel.add(versionLabel, gridBagConstraints1);

    dateLabel.setText(LanguageBundle.getString("in_abt_release_date")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 1, GridBagConstraints.WEST);
    aCreditsPanel.add(dateLabel, gridBagConstraints1);

    javaVersionLabel.setText(LanguageBundle.getString("in_abt_java_version")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 2, GridBagConstraints.WEST);
    aCreditsPanel.add(javaVersionLabel, gridBagConstraints1);

    leaderLabel.setText(LanguageBundle.getString("in_abt_BD")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 3, GridBagConstraints.WEST);
    aCreditsPanel.add(leaderLabel, gridBagConstraints1);

    wwwLink.setText(LanguageBundle.getString("in_abt_web")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 4, GridBagConstraints.WEST);
    aCreditsPanel.add(wwwLink, gridBagConstraints1);

    emailLabel.setText(LanguageBundle.getString("in_abt_email")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 5, GridBagConstraints.WEST);
    aCreditsPanel.add(emailLabel, gridBagConstraints1);

    helperLabel.setText(LanguageBundle.getString("in_abt_monkeys")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 6, GridBagConstraints.NORTHWEST);
    aCreditsPanel.add(helperLabel, gridBagConstraints1);

    // Info

    version.setEditable(false);
    String versionNum = PCGenPropBundle.getVersionNumber();
    if (StringUtils.isNotBlank(PCGenPropBundle.getAutobuildNumber())) {
        versionNum += " autobuild #" + PCGenPropBundle.getAutobuildNumber();
    }
    version.setText(versionNum);
    version.setBorder(null);
    version.setOpaque(false);

    gridBagConstraints1 = buildConstraints(1, 0, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints1.weightx = 1.0;
    aCreditsPanel.add(version, gridBagConstraints1);

    releaseDate.setEditable(false);
    String releaseDateStr = PCGenPropBundle.getReleaseDate();
    if (StringUtils.isNotBlank(PCGenPropBundle.getAutobuildDate())) {
        releaseDateStr = PCGenPropBundle.getAutobuildDate();
    }
    releaseDate.setText(releaseDateStr);
    releaseDate.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    releaseDate.setOpaque(false);

    gridBagConstraints1 = buildConstraints(1, 1, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    aCreditsPanel.add(releaseDate, gridBagConstraints1);

    javaVersion.setEditable(false);
    javaVersion.setText(
            System.getProperty("java.runtime.version") + " (" + System.getProperty("java.vm.vendor") + ")");
    javaVersion.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    javaVersion.setOpaque(false);

    gridBagConstraints1 = buildConstraints(1, 2, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    aCreditsPanel.add(javaVersion, gridBagConstraints1);

    projectLead.setEditable(false);
    projectLead.setText(PCGenPropBundle.getHeadCodeMonkey());
    projectLead.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    projectLead.setOpaque(false);

    gridBagConstraints1 = buildConstraints(1, 3, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    aCreditsPanel.add(projectLead, gridBagConstraints1);

    // Web site button
    wwwSite.setText(PCGenPropBundle.getWWWHome());
    wwwSite.addActionListener(event -> {
        try {
            DesktopBrowserLauncher.viewInBrowser(new URL(wwwSite.getText()));
        } catch (IOException ioe) {
            Logging.errorPrint(LanguageBundle.getString("in_abt_browser_err"), ioe); //$NON-NLS-1$
        }
    });
    gridBagConstraints1 = buildConstraints(1, 4, GridBagConstraints.WEST);
    aCreditsPanel.add(wwwSite, gridBagConstraints1);

    // Mailing list button
    mailingList.setText(PCGenPropBundle.getMailingList());
    mailingList.addActionListener(event -> {
        try {
            DesktopBrowserLauncher.viewInBrowser(new URL(mailingList.getText()));
        } catch (IOException ioe) {
            Logging.errorPrint(LanguageBundle.getString("in_err_browser_err"), ioe); //$NON-NLS-1$
        }
    });
    gridBagConstraints1 = buildConstraints(1, 5, GridBagConstraints.WEST);
    aCreditsPanel.add(mailingList, gridBagConstraints1);

    // Monkey tabbed pane
    gridBagConstraints1 = buildConstraints(1, 6, GridBagConstraints.WEST);
    gridBagConstraints1.gridwidth = 2;
    gridBagConstraints1.weighty = 1.0;
    gridBagConstraints1.fill = GridBagConstraints.BOTH;
    aCreditsPanel.add(monkeyTabPane, gridBagConstraints1);

    monkeyTabPane.add(LanguageBundle.getString("in_abt_code_mky"), //$NON-NLS-1$
            buildMonkeyList(PCGenPropBundle.getCodeMonkeys()));
    monkeyTabPane.add(LanguageBundle.getString("in_abt_list_mky"), //$NON-NLS-1$
            buildMonkeyList(PCGenPropBundle.getListMonkeys()));
    monkeyTabPane.add(LanguageBundle.getString("in_abt_test_mky"), //$NON-NLS-1$
            buildMonkeyList(PCGenPropBundle.getTestMonkeys()));
    monkeyTabPane.add(LanguageBundle.getString("in_abt_eng_mky"), //$NON-NLS-1$
            buildMonkeyList(PCGenPropBundle.getEngineeringMonkeys()));

    // because there isn't one
    monkeyTabPane.setToolTipTextAt(2, LanguageBundle.getString("in_abt_easter_egg")); //$NON-NLS-1$

    return aCreditsPanel;
}