Example usage for javax.swing JComponent setToolTipText

List of usage examples for javax.swing JComponent setToolTipText

Introduction

In this page you can find the example usage for javax.swing JComponent 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:net.sf.mzmine.chartbasics.graphicsexport.GraphicsExportDialog.java

/**
 * Create the dialog.//from   w  w w  . j ava2s . c o m
 */
public GraphicsExportDialog() {
    final JFrame thisframe = this;
    //
    parameters = new GraphicsExportParameters();
    chartParam = new ChartThemeParameters();
    parametersAndComponents = new HashMap<String, JComponent>();

    String[] formats = parameters.getParameter(GraphicsExportParameters.exportFormat).getChoices();
    chooser.addChoosableFileFilter(new FileTypeFilter(formats, "Export images"));
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    //
    setBounds(100, 100, 808, 795);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new MigLayout("", "[][][grow]", "[][][][grow]"));
    {
        StringParameter p = parameters.getParameter(GraphicsExportParameters.path);
        StringComponent txtPath = p.createEditingComponent();
        contentPanel.add(txtPath, "flowx,cell 0 0,growx");
        parametersAndComponents.put(p.getName(), txtPath);
    }
    {
        btnPath = new JButton("Path");
        btnPath.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                choosePath();
            }
        });
        contentPanel.add(btnPath, "cell 1 0");
    }
    {
        StringParameter p = parameters.getParameter(GraphicsExportParameters.filename);
        StringComponent txtFileName = p.createEditingComponent();
        contentPanel.add(txtFileName, "cell 0 1,growx");
        parametersAndComponents.put(p.getName(), txtFileName);
    }
    {
        JLabel lblFilename = new JLabel("filename");
        contentPanel.add(lblFilename, "cell 1 1");
    }
    {
        JPanel pnSettingsLeft = new JPanel();
        pnSettingsLeft.setMinimumSize(new Dimension(260, 260));
        contentPanel.add(pnSettingsLeft, "cell 0 3,grow");
        pnSettingsLeft.setLayout(new BorderLayout(0, 0));
        {

            GridBagPanel pn = new GridBagPanel();
            {
                // add unit
                UserParameter p;
                JComponent comp;
                // add unit
                p = (UserParameter) parameters.getParameter(GraphicsExportParameters.unit);
                comp = p.createEditingComponent();
                comp.setToolTipText(p.getDescription());
                comp.setEnabled(true);
                pn.add(comp, 2, 2);
                parametersAndComponents.put(p.getName(), comp);

                int i = 0;
                // add export settings
                Parameter[] param = parameters.getParameters();
                for (int pi = 3; pi < param.length; pi++) {
                    p = (UserParameter) param[pi];
                    comp = p.createEditingComponent();
                    comp.setToolTipText(p.getDescription());
                    comp.setEnabled(true);
                    pn.add(new JLabel(p.getName()), 0, i);
                    pn.add(comp, 1, i, 1, 1, 1, 1);
                    // add to map
                    parametersAndComponents.put(p.getName(), comp);
                    i++;
                }

                // add separator
                pn.add(new JSeparator(), 0, i, 5, 1, 1, 1, GridBagConstraints.BOTH);
                i++;
                // add Apply theme button
                JButton btnApply2 = new JButton("Apply theme");
                btnApply2.addActionListener(e -> applyTheme());
                pn.add(btnApply2, 0, i, 5, 1, 1, 1, GridBagConstraints.BOTH);
                i++;

                // add chart settings
                param = chartParam.getParameters();
                for (int pi = 0; pi < param.length; pi++) {
                    p = (UserParameter) param[pi];
                    comp = p.createEditingComponent();
                    comp.setToolTipText(p.getDescription());
                    comp.setEnabled(true);
                    pn.add(new JLabel(p.getName()), 0, i);
                    pn.add(comp, 1, i, 4, 1);
                    // add to map
                    parametersAndComponents.put(p.getName(), comp);
                    i++;
                }

                // add listener to master font
                JFontSpecs master = (JFontSpecs) parametersAndComponents
                        .get(chartParam.getParameter(ChartThemeParameters.masterFont).getName());
                master.addListener(fspec -> {
                    if (listenersEnabled)
                        handleMasterFontChanged(fspec);
                });
            }

            JScrollPane scrollPane = new JScrollPane(pn);
            scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            pnSettingsLeft.add(scrollPane, BorderLayout.CENTER);
            scrollPane.getVerticalScrollBar().setUnitIncrement(18);
            scrollPane.revalidate();
            scrollPane.repaint();
        }
    }
    {
        {
            pnChartPreview = new JPanel();
            pnChartPreview.setLayout(null);
            contentPanel.add(pnChartPreview, "cell 1 3 2 1,grow");
        }
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton okButton = new JButton("Save");
            okButton.addActionListener(e -> saveGraphicsAs());
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            btnRenewPreview = new JButton("Renew Preview");
            btnRenewPreview.addActionListener(e -> renewPreview());
            buttonPane.add(btnRenewPreview);
        }
        {
            btnApply = new JButton("Apply theme");
            btnApply.addActionListener(e -> applyTheme());
            buttonPane.add(btnApply);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(e -> setVisible(false));
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
    // set all to components
    updateComponentsFromParameters();
}

From source file:com.sec.ose.osi.ui.frm.main.identification.stringmatch.table.JTableInfoForSMFile.java

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
            column);//from w w w  .  j  ava 2 s. com
    if (value != null) {
        if (table.getColumnName(column).equals("Version") || table.getColumnName(column).equals("Pending Hits")
                || table.getColumnName(column).equals("Status")
                || table.getColumnName(column).equals("Identified Hits")
                || table.getColumnName(column).equals("Files")) {
            setHorizontalAlignment(SwingConstants.CENTER);
        } else {
            setHorizontalAlignment(SwingConstants.LEFT);
        }

        comp.setToolTipText(String.valueOf(value));
        if (table.getValueAt(row, TableModelForSMFile.COL_STATUS) != null
                && table.getValueAt(row, TableModelForSMFile.COL_STATUS).toString().equals("Identified")) {

            comp.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 12));
            comp.setForeground(new Color(20, 20, 20));
        } else if (table.getValueAt(row, TableModelForSMFile.COL_STATUS).toString().equals("Declared")) {
            comp.setForeground(new Color(150, 150, 150));
        } else {
            comp.setForeground(new Color(20, 20, 20));
        }
    } else {
        comp.setToolTipText(null);
    }
    return comp;
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopLookupField.java

@Override
public void setDescription(String description) {
    if (!Objects.equals(this.getDescription(), description)) {
        JComponent editorComponent = (JComponent) comboBox.getEditor().getEditorComponent();

        editorComponent.setToolTipText(description);
        DesktopToolTipManager.getInstance().registerTooltip(editorComponent);

        requestContainerUpdate();/*  www .ja va  2  s.c  o m*/
    }
}

From source file:eu.ggnet.dwoss.receipt.unit.UnitView.java

private void updateValidationStatus(JComponent component, Survey vs, StringBuilder sb) {
    EventQueue.invokeLater(() -> {
        component.setToolTipText(vs.getMessage());
        component.setForeground(vs.getStatus().getColor());
    });//from  ww w .  j a va  2 s .c om
    sb.append("- ").append(component.getName()).append(": ").append(vs.getStatus()).append(" : ")
            .append(vs.getMessage()).append("\n");
}

From source file:net.sf.jsignpdf.VisibleSignatureDialog.java

/**
 * Sets tooltip with given key to given component
 * //from  w w w .  j  ava2s  .  co  m
 * @param aComponent
 *            component to which a tooltip should be assigned
 * @param aKey
 *            tooltip key (in resource bundle)
 */
private void setToolTip(final JComponent aComponent, final String aKey) {
    aComponent.setToolTipText(RES.get(aKey));
}

From source file:com.all.login.view.NewAccountFormPanel.java

private void settingsForRightText(JComponent field, String originalName) {
    field.setToolTipText(null);
    field.setName(originalName);
}

From source file:com.anrisoftware.prefdialog.core.AbstractFieldComponent.java

private void setupToolTipText() {
    if (component instanceof JComponent) {
        JComponent jcomponent = (JComponent) component;
        jcomponent.setToolTipText(toolTip);
    }/*from www . j a v a2 s . c o  m*/
}

From source file:davmail.ui.SettingsFrame.java

protected void addSettingComponent(JPanel panel, String label, JComponent component, String toolTipText) {
    JLabel fieldLabel = new JLabel(label);
    fieldLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    fieldLabel.setVerticalAlignment(SwingConstants.CENTER);
    panel.add(fieldLabel);/*from w ww  .ja v  a  2 s .  com*/
    component.setMaximumSize(component.getPreferredSize());
    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));
    innerPanel.add(component);
    panel.add(innerPanel);
    if (toolTipText != null) {
        fieldLabel.setToolTipText(toolTipText);
        component.setToolTipText(toolTipText);
    }
}

From source file:com.all.login.view.NewAccountFormPanel.java

private void showViolationMessage(JComponent field, String propertyName,
        Set<ConstraintViolation<RegisterUserCommand>> violations) {
    field.setName("invalidTextField34" + propertyName);
    StringBuffer sb = new StringBuffer();
    HashMap<String, String> map = new HashMap<String, String>();
    for (ConstraintViolation<RegisterUserCommand> violation : violations) {
        map.put(violation.getMessage(), "");
    }//from   w  w  w .ja  va 2  s.  c  o m
    Set<String> messages = map.keySet();
    for (String violation : messages) {
        sb.append(violation);
    }
    field.setToolTipText(sb.toString());
}

From source file:davmail.ui.SettingsFrame.java

protected void addPortSettingComponent(JPanel panel, String label, JComponent component,
        JComponent checkboxComponent, JComponent checkboxSSLComponent, String toolTipText) {
    JLabel fieldLabel = new JLabel(label);
    fieldLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    fieldLabel.setVerticalAlignment(SwingConstants.CENTER);
    panel.add(fieldLabel);//  w  w  w .j a v a  2  s  .c  om
    component.setMaximumSize(component.getPreferredSize());
    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));
    innerPanel.add(checkboxComponent);
    innerPanel.add(component);
    innerPanel.add(checkboxSSLComponent);
    panel.add(innerPanel);
    if (toolTipText != null) {
        fieldLabel.setToolTipText(toolTipText);
        component.setToolTipText(toolTipText);
    }
}