Java Code Examples for javax.swing.AbstractButton#setToolTipText()

The following examples show how to use javax.swing.AbstractButton#setToolTipText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableViewPagePanel.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void initComponents() {
    final AbstractButton switchToChartButton = ToolButtonFactory.createButton(iconForSwitchToChartButton, false);
    switchToChartButton.setToolTipText("Switch to Chart View");
    switchToChartButton.setName("switchToChartButton");
    switchToChartButton.setEnabled(hasAlternativeView());
    switchToChartButton.addActionListener(e -> showAlternativeView());

    final JPanel buttonPanel = new JPanel(new BorderLayout());
    buttonPanel.add(switchToChartButton, BorderLayout.NORTH);
    buttonPanel.add(getHelpButton(), BorderLayout.SOUTH);

    add(buttonPanel, BorderLayout.EAST);

    table = new JTable();
    table.removeEditor();
    table.setGridColor(Color.LIGHT_GRAY.brighter());
    table.addMouseListener(new PagePanel.PopupHandler());
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    final JScrollPane scrollPane = new JScrollPane(table);

    add(scrollPane, BorderLayout.CENTER);
}
 
Example 2
Source File: TimeSeriesMatrixTopComponent.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private JPanel createButtonPanel() {
    final TableLayout tableLayout = new TableLayout(1);
    tableLayout.setTablePadding(4, 4);
    tableLayout.setRowPadding(0, new Insets(0, 4, 4, 4));
    tableLayout.setTableAnchor(TableLayout.Anchor.NORTHWEST);
    tableLayout.setTableFill(TableLayout.Fill.HORIZONTAL);
    tableLayout.setTableWeightX(1.0);
    tableLayout.setTableWeightY(0.0);
    JPanel buttonPanel = new JPanel(tableLayout);

    AbstractButton helpButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help22.png"), false);
    helpButton.addActionListener(e -> new HelpCtx(HELP_ID).display());
    helpButton.setToolTipText("Help");
    buttonPanel.add(matrixSizeSpinner);
    buttonPanel.add(tableLayout.createVerticalSpacer());
    buttonPanel.add(helpButton);

    return buttonPanel;
}
 
Example 3
Source File: IconLoader.java    From swift-k with Apache License 2.0 6 votes vote down vote up
public static void setIcon(AbstractButton button, String res, String alt) {
    try {
        URL url = GraphsPanel.class.getClassLoader().getResource(res);
        if (url == null) {
            button.setText(alt);
        }
        else {
            BufferedImage icon = ImageIO.read(url);
            button.setIcon(new ImageIcon(icon));
        }
    }
    catch (Exception e) {
        button.setText(alt);
    }
    button.setToolTipText(alt);
}
 
Example 4
Source File: MosaicExpressionsPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private Component createMoveVariableDownButton() {
    AbstractButton moveVariableDownButton = createButton("icons/MoveDown24.gif", "moveVariableDown");
    moveVariableDownButton.setToolTipText("Move down selected rows."); /*I18N*/
    moveVariableDownButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            moveRowsDown(variablesTable, variablesTable.getSelectedRows());
        }
    });
    return moveVariableDownButton;
}
 
Example 5
Source File: GridBagCustomizer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Updates the state of those pushbuttons in the left
 * vertical tool box that need to indicate the special "ambiguous"
 * state marking that some of the currently selected components
 * have the respective property set while some do not.
 */
private void updateButton(AbstractButton button, boolean nonEmptySelection, boolean allSelectedUnambiguous, String iconWarning, String toolTipWarning, String iconNormal, String toolTipNormal) {
    button.setSelected(allSelectedUnambiguous);
    if(nonEmptySelection && !allSelectedUnambiguous) {
        button.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/layoutsupport/griddesigner/resources/" + iconWarning, false)); // NOI18N
        button.setToolTipText(NbBundle.getMessage(GridBagCustomizer.class, "GridBagCustomizer." + toolTipWarning)); // NOI18N
    } else {
        button.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/layoutsupport/griddesigner/resources/" + iconNormal, false)); // NOI18N
        button.setToolTipText(NbBundle.getMessage(GridBagCustomizer.class, "GridBagCustomizer." + toolTipNormal)); // NOI18N
    }
}
 
Example 6
Source File: TimeSeriesPlayerForm.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private AbstractButton createMinusButton() {
    final AbstractButton minusButton = ToolButtonFactory.createButton(minusIcon, false);
    minusButton.setToolTipText("Decrease playing speed");
    minusButton.addActionListener(e -> {
        if (speedSlider.getValue() > speedSlider.getMinimum()) {
            speedSlider.setValue(speedSlider.getValue() - 1);
        }
    });
    return minusButton;
}
 
Example 7
Source File: BinningConfigurationPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private JPanel createVariablesPanel() {
    final Grid grid = new Grid(5, false);
    TableLayout gridLayout = grid.getLayout();
    gridLayout.setTablePadding(4, 3);
    gridLayout.setTableAnchor(TableLayout.Anchor.NORTHWEST);
    gridLayout.setColumnFill(2, TableLayout.Fill.HORIZONTAL);
    gridLayout.setColumnWeightX(2, 1.0);
    grid.setHeaderRow(
            /*0*/ //selection column
            /*1*/ new JLabel("<html><b>Name</b>"),
            /*2*/ new JLabel("<html><b>Expression</b>"),
            /*3*/ new JLabel("<html><b>Valid-Pixel Expression</b>"),
            /*5*/ null // column for edit button
    );

    variableTableController = new VariableTableController(grid, binningFormModel);
    final ListControlBar gridControlBar = ListControlBar.create(ListControlBar.HORIZONTAL, grid, variableTableController);

    final AbstractButton sel = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ShowSelection16.png"), true);
    sel.setToolTipText("Show/hide selection column");
    sel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            grid.setShowSelectionColumn(sel.isSelected());
            gridControlBar.updateState();
        }
    });
    gridControlBar.add(sel, 0);

    JPanel panel = new JPanel(new BorderLayout(4, 4));
    panel.setBorder(new TitledBorder("Intermediate Source Bands (optional)"));
    panel.add(gridControlBar, BorderLayout.NORTH);
    panel.add(new JScrollPane(grid), BorderLayout.CENTER);
    return panel;
}
 
Example 8
Source File: PagePanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
protected AbstractButton getHelpButton() {
        if (helpId != null) {
            final AbstractButton helpButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help22.png"),
                                                                             false);
            helpButton.setToolTipText("Help.");
            helpButton.setName("helpButton");
            helpButton.addActionListener(e -> parentComponent.getHelpCtx().display());
//            HelpSys.enableHelpKey(getParentDialogContentPane(), helpId);
            return helpButton;
        }

        return null;
    }
 
Example 9
Source File: CommonMenuText.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @param m the button item to change the text, short description and mnemonic
 * @param substitutes substitutes to use in a message format
 * @param prop key bundle to use
 */
public static void name(AbstractButton m, String prop, Object... substitutes)
{
	m.setText(getName(prop, substitutes));
	String shortDesc = getShortDesc(prop, substitutes);
	if (shortDesc != null && !shortDesc.isEmpty())
	{
		m.setToolTipText(shortDesc);
	}
	m.setMnemonic(getMnemonic(prop));
}
 
Example 10
Source File: BinningConfigurationPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private JPanel createAggregatorsPanel() {
    final Grid grid = new Grid(6, false);
    TableLayout gridLayout = grid.getLayout();
    gridLayout.setTablePadding(4, 3);
    gridLayout.setTableAnchor(TableLayout.Anchor.NORTHWEST);
    gridLayout.setColumnFill(2, TableLayout.Fill.HORIZONTAL);
    gridLayout.setColumnFill(3, TableLayout.Fill.HORIZONTAL);
    gridLayout.setColumnFill(4, TableLayout.Fill.HORIZONTAL);
    gridLayout.setColumnWeightX(2, 1.0);
    gridLayout.setColumnWeightX(3, 1.0);
    gridLayout.setColumnWeightX(4, 1.0);
    grid.setHeaderRow(
            /*0*/ //selection column
            /*1*/ new JLabel("<html><b>Aggregator</b>"),
            /*2*/ new JLabel("<html><b>Source Bands</b>"),
            /*3*/ new JLabel("<html><b>Parameters</b>"),
            /*4*/ new JLabel("<html><b>Target Bands</b>"),
            /*5*/ null // column for edit button
    );
    aggregatorTableController = new AggregatorTableController(grid, binningFormModel);
    final ListControlBar gridControlBar = ListControlBar.create(ListControlBar.HORIZONTAL, grid, aggregatorTableController);

    final AbstractButton sel = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ShowSelection16.png"), true);
    sel.setToolTipText("Show/hide selection column");
    sel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            grid.setShowSelectionColumn(sel.isSelected());
            gridControlBar.updateState();
        }
    });
    gridControlBar.add(sel, 0);

    JPanel panel = new JPanel(new BorderLayout(4, 4));
    panel.setBorder(new EmptyBorder(4, 4, 4, 4));
    panel.add(gridControlBar, BorderLayout.NORTH);
    panel.add(new JScrollPane(grid), BorderLayout.CENTER);
    return panel;
}
 
Example 11
Source File: MosaicExpressionsPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private Component createNewConditionButton() {
    AbstractButton newConditionsButton = createButton("icons/Plus24.gif", "newCondition");
    newConditionsButton.setToolTipText("Add new processing condition"); /*I18N*/
    newConditionsButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final int rows = conditionsTable.getRowCount();
            addRow(conditionsTable, new Object[]{"condition_" + rows, "", false}); /*I18N*/
        }
    });
    return newConditionsButton;
}
 
Example 12
Source File: MosaicExpressionsPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private Component createRemoveConditionButton() {
    AbstractButton removeConditionButton = createButton("icons/Minus24.gif", "removeCondition");
    removeConditionButton.setToolTipText("Remove selected rows."); /*I18N*/
    removeConditionButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            removeRows(conditionsTable, conditionsTable.getSelectedRows());
        }
    });
    return removeConditionButton;
}
 
Example 13
Source File: MosaicExpressionsPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private Component createNewVariableButton() {
    AbstractButton newVariableButton = createButton("icons/Plus24.gif", "newVariable");
    newVariableButton.setToolTipText("Add new processing variable"); /*I18N*/
    newVariableButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final int rows = variablesTable.getRowCount();
            addRow(variablesTable, new Object[]{"variable_" + rows, ""}); /*I18N*/
        }
    });
    return newVariableButton;
}
 
Example 14
Source File: MosaicExpressionsPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private Component createMoveVariableUpButton() {
    AbstractButton moveVariableUpButton = createButton("icons/MoveUp24.gif", "moveVariableUp");
    moveVariableUpButton.setToolTipText("Move up selected rows."); /*I18N*/
    moveVariableUpButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            moveRowsUp(variablesTable, variablesTable.getSelectedRows());
        }
    });
    return moveVariableUpButton;
}
 
Example 15
Source File: TimeSeriesGraphForm.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private JPanel createButtonPanel(final String helpID) {
        showTimeSeriesForSelectedPinsButton = ToolButtonFactory.createButton(
                    UIUtils.loadImageIcon("icons/SelectedPinSpectra24.gif"), true);
        showTimeSeriesForSelectedPinsButton.addActionListener(e -> {
            if (graphModel.isShowingAllPins()) {
                showTimeSeriesForAllPinsButton.setSelected(false);
                graphModel.setIsShowingAllPins(false);
            }
            graphModel.setIsShowingSelectedPins(showTimeSeriesForSelectedPinsButton.isSelected());
        });
        showTimeSeriesForSelectedPinsButton.setName("showTimeSeriesForSelectedPinsButton");
        showTimeSeriesForSelectedPinsButton.setToolTipText("Show time series for selected pin");

        //////////////////////////////////////////

        showTimeSeriesForAllPinsButton = ToolButtonFactory.createButton(
                    UIUtils.loadImageIcon("icons/PinSpectra24.gif"), true);
        showTimeSeriesForAllPinsButton.addActionListener(e -> {
            if (graphModel.isShowingSelectedPins()) {
                showTimeSeriesForSelectedPinsButton.setSelected(false);
                graphModel.setIsShowingSelectedPins(false);
            }
            graphModel.setIsShowingAllPins(showTimeSeriesForAllPinsButton.isSelected());
        });
        showTimeSeriesForAllPinsButton.setName("showTimeSeriesForAllPinsButton");
        showTimeSeriesForAllPinsButton.setToolTipText("Show time series for all pins");

        //////////////////////////////////////////

        showCursorTimeSeriesButton = ToolButtonFactory.createButton(
                    UIUtils.loadImageIcon("icons/CursorSpectrum24.gif"), true);
        showCursorTimeSeriesButton.addActionListener(e -> graphModel.setIsShowingCursorTimeSeries(showCursorTimeSeriesButton.isSelected()));
        showCursorTimeSeriesButton.setToolTipText("Show time series for cursor");
        showCursorTimeSeriesButton.setSelected(true);

        //////////////////////////////////////////

        exportTimeSeriesButton = ToolButtonFactory.createButton(
                    UIUtils.loadImageIcon("icons/Export24.gif"),
                    false);
        exportTimeSeriesButton.addActionListener(e -> {
            final ProductSceneView view = SnapApp.getDefault().getSelectedProductSceneView();

            JOptionPane.showMessageDialog(view, "Not available in the current version.", "Export data", JOptionPane.INFORMATION_MESSAGE);

            //@todo se remove message dialog and fix export that only the visible graph data will be exported
//                if (view != null
//                    && view.getProduct() != null
//                    && view.getProduct().getProductType().equals(AbstractTimeSeries.TIME_SERIES_PRODUCT_TYPE)
//                    && TimeSeriesMapper.getInstance().getTimeSeries(view.getProduct()) != null) {
//
//                    AbstractTimeSeries timeSeries = TimeSeriesMapper.getInstance().getTimeSeries(view.getProduct());
//                    ExportTimeBasedText.export(mainPanel, timeSeries, helpID);
//                }
        });
        exportTimeSeriesButton.setToolTipText("Export raster data time series of all pins");
        exportTimeSeriesButton.setName("exportTimeSeriesButton");
        final ProductSceneView sceneView = SnapApp.getDefault().getSelectedProductSceneView();
        if (sceneView != null) {
            exportTimeSeriesButton.setEnabled(sceneView.getProduct().getPinGroup().getNodeCount() > 0);
        } else {
            exportTimeSeriesButton.setEnabled(false);
        }

        AbstractButton helpButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help22.png"), false);
        helpButton.addActionListener(e -> new HelpCtx(helpID).display());
        helpButton.setToolTipText("Help");

        final TableLayout tableLayout = new TableLayout(1);
        tableLayout.setTablePadding(4, 4);
        tableLayout.setTableAnchor(TableLayout.Anchor.NORTHWEST);
        tableLayout.setTableFill(TableLayout.Fill.HORIZONTAL);
        tableLayout.setTableWeightX(1.0);
        tableLayout.setTableWeightY(0.0);
        JPanel buttonPanel = new JPanel(tableLayout);

        buttonPanel.add(showTimeSeriesForSelectedPinsButton);
        buttonPanel.add(showTimeSeriesForAllPinsButton);
        buttonPanel.add(showCursorTimeSeriesButton);
        buttonPanel.add(exportTimeSeriesButton);
        buttonPanel.add(tableLayout.createVerticalSpacer());
        buttonPanel.add(helpButton);
        return buttonPanel;
    }
 
Example 16
Source File: TimeSeriesPlayerForm.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private AbstractButton createRepeatButton() {
    final AbstractButton repeatButton = ToolButtonFactory.createButton(repeatIcon, true);
    repeatButton.setToolTipText("Toggle repeat");
    return repeatButton;
}
 
Example 17
Source File: ChartPagePanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private JPanel createChartBottomPanel(final ChartPanel chartPanel) {

        final AbstractButton zoomAllButton = ToolButtonFactory.createButton(
                UIUtils.loadImageIcon("icons/view-fullscreen.png"),
                false);
        zoomAllButton.setToolTipText("Zoom all.");
        zoomAllButton.setName("zoomAllButton.");
        zoomAllButton.addActionListener(e -> {
            chartPanel.restoreAutoBounds();
            chartPanel.repaint();
        });

        final AbstractButton propertiesButton = ToolButtonFactory.createButton(
                UIUtils.loadImageIcon("icons/Edit24.gif"),
                false);
        propertiesButton.setToolTipText("Edit properties.");
        propertiesButton.setName("propertiesButton.");
        propertiesButton.addActionListener(e -> chartPanel.doEditChartProperties());

        final AbstractButton saveButton = ToolButtonFactory.createButton(
                UIUtils.loadImageIcon("icons/Export24.gif"),
                false);
        saveButton.setToolTipText("Save chart as image.");
        saveButton.setName("saveButton.");
        saveButton.addActionListener(e -> {
            try {
                chartPanel.doSaveAs();
            } catch (IOException e1) {
                AbstractDialog.showErrorDialog(chartPanel, "Could not save chart:\n" + e1.getMessage(), "Error");
            }
        });

        final AbstractButton printButton = ToolButtonFactory.createButton(
                UIUtils.loadImageIcon("icons/Print24.gif"),
                false);
        printButton.setToolTipText("Print chart.");
        printButton.setName("printButton.");
        printButton.addActionListener(e -> chartPanel.createChartPrintJob());

        final TableLayout tableLayout = new TableLayout(6);
        tableLayout.setColumnFill(4, TableLayout.Fill.HORIZONTAL);
        tableLayout.setColumnWeightX(4, 1.0);
        JPanel buttonPanel = new JPanel(tableLayout);
        tableLayout.setRowPadding(0, new Insets(0, 4, 0, 0));
        buttonPanel.add(zoomAllButton);
        tableLayout.setRowPadding(0, new Insets(0, 0, 0, 0));
        buttonPanel.add(propertiesButton);
        buttonPanel.add(saveButton);
        buttonPanel.add(printButton);
        buttonPanel.add(new JPanel());
        buttonPanel.add(getHelpButton());

        return buttonPanel;
    }
 
Example 18
Source File: LogDisplay.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
static AbstractButton createButton() {
    final AbstractButton logDisplayButton = ImageInfoEditorSupport.createToggleButton("org/esa/snap/rcp/icons/LogDisplay24.png");
    logDisplayButton.setName("logDisplayButton");
    logDisplayButton.setToolTipText("Switch to logarithmic display"); /*I18N*/
    return logDisplayButton;
}
 
Example 19
Source File: Lang.java    From drmips with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Shortcut function to translate a button type component.
 * @param btn Button type component.
 * @param key Key of the button text string.
 * @param tooltipKey Key of the button tooltip string.
 * @param textArgs Text string arguments values.
 * @param tooltipArgs Tooltip string arguments values.
 */
public static void tButton(AbstractButton btn, String key, String tooltipKey, Object[] textArgs, Object[] tooltipArgs) {
	tButton(btn, key, textArgs);
	btn.setToolTipText(t(tooltipKey, tooltipArgs));
}
 
Example 20
Source File: Lang.java    From drmips with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Shortcut function to translate a button type component.
 * @param btn Button type component.
 * @param key Key of the button text string.
 * @param tooltipKey Key of the button tooltip string.
 */
public static void tButton(AbstractButton btn, String key, String tooltipKey) {
	tButton(btn, key);
	btn.setToolTipText(t(tooltipKey));
}