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

The following examples show how to use javax.swing.AbstractButton#setName() . 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: AbstractToolbarFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void configureToolbarButton (AbstractButton item, String containerCtx, String action, ActionProvider provider, Map ctx) {
        item.setFocusable(false);
        item.setName(action);
        item.putClientProperty (KEY_ACTION, action);
        item.setToolTipText(
            provider.getDisplayName(action, containerCtx));
//        item.setToolTipText(provider.getDescription(action, containerCtx));
        int state = ctx == null ? ActionProvider.STATE_VISIBLE :
            provider.getState (action, containerCtx, ctx);
        boolean enabled = (state & ActionProvider.STATE_ENABLED) != 0;
        item.setEnabled(enabled);
        boolean visible = (state & ActionProvider.STATE_VISIBLE) != 0;
        item.setVisible (visible);
        boolean toggled = (state & ActionProvider.STATE_SELECTED) != 0;
        item.setSelected(toggled);
//        item.setMnemonic(provider.getMnemonic(action, containerCtx));
//        item.setDisplayedMnemonicIndex(provider.getMnemonicIndex(action, containerCtx));
        item.setIcon(provider.getIcon(action, containerCtx, BeanInfo.ICON_COLOR_16x16));
    }
 
Example 2
Source File: ToolButtonFactory.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private static void setButtonName(AbstractButton button, Action action) {
    if (button.getName() == null) {
        String name = null;

        Object value = action.getValue(Action.ACTION_COMMAND_KEY);
        if (value != null) {
            name = value.toString();
        } else {
            value = action.getValue(Action.NAME);
            if (value != null) {
                name = value.toString();
            }
        }
        if (name != null) {
            button.setName(name);
        }
    }
}
 
Example 3
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 4
Source File: CompactNavigationPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected Component createPreviousButton() {
	AbstractButton button = NavigationButtons.createPrev();
	button.setName(PREV_BUTTON_NAME);
	installPreviousButtonListeners(button);
	return button;
}
 
Example 5
Source File: CompactNavigationPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected Component createNextButton() {
	AbstractButton button = NavigationButtons.createNext();
	button.setName(NEXT_BUTTON_NAME);
	installNextButtonListeners(button);
	return button;
}
 
Example 6
Source File: LargeNavigationPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected Component createPreviousButton() {
	AbstractButton button = NavigationButtons.createPrev();
	format(button);
	button.setIcon(new TriangleIcon(SwingConstants.WEST, 24, 24,
			Color.lightGray));
	button.setRolloverIcon(new TriangleIcon(SwingConstants.WEST, 24, 24,
			Color.white));
	button.setDisabledIcon(new TriangleIcon(SwingConstants.WEST, 24, 24,
			Color.darkGray));
	button.setName(PREV_BUTTON_NAME);
	installPreviousButtonListeners(button);
	return button;
}
 
Example 7
Source File: LargeNavigationPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected Component createNextButton() {
	AbstractButton button = NavigationButtons.createNext();
	format(button);
	button.setIcon(new TriangleIcon(SwingConstants.EAST, 24, 24,
			Color.lightGray));
	button.setRolloverIcon(new TriangleIcon(SwingConstants.EAST, 24, 24,
			Color.white));
	button.setDisabledIcon(new TriangleIcon(SwingConstants.EAST, 24, 24,
			Color.darkGray));
	button.setName(NEXT_BUTTON_NAME);
	installNextButtonListeners(button);
	return button;
}
 
Example 8
Source File: LargeNavigationPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
protected AbstractButton createFirstButton() {
	AbstractButton button = new JButton();
	format(button);
	button.setIcon(new FirstIcon(2, 24, 24, Color.lightGray));
	button.setRolloverIcon(new FirstIcon(2, 24, 24, Color.white));
	button.setDisabledIcon(new FirstIcon(2, 24, 24, Color.darkGray));
	button.setName("Spinner.firstButton");
	installFirstButtonListeners(button);
	return button;
}
 
Example 9
Source File: LargeNavigationPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
protected AbstractButton createLastButton() {
	AbstractButton button = new JButton();
	format(button);
	button.setIcon(new LastIcon(2, 24, 24, Color.lightGray));
	button.setRolloverIcon(new LastIcon(2, 24, 24, Color.white));
	button.setDisabledIcon(new LastIcon(2, 24, 24, Color.darkGray));
	button.setName("Spinner.lastButton");
	installLastButtonListeners(button);
	return button;
}
 
Example 10
Source File: MaskToolTopComponent.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public void initUI() {
    setLayout(new BorderLayout());
    maskForm = createMaskForm(this, e -> {
        final ProductSceneView sceneView = getSelectedProductSceneView();
        if (sceneView != null) {
            Mask selectedMask = maskForm.getSelectedMask();
            if (selectedMask != null) {
                VectorDataNode vectorDataNode = Mask.VectorDataType.getVectorData(selectedMask);
                if (vectorDataNode != null) {
                    sceneView.selectVectorDataLayer(vectorDataNode);
                }
            }
        }
    });

    AbstractButton helpButton = maskForm.getHelpButton();
    if (helpButton != null) {
        helpButton.addActionListener(e -> getHelpCtx().display());
        helpButton.setName("helpButton");
    }

    updateMaskForm(getSelectedProductSceneView());

    SnapApp.getDefault().getProductManager().addListener(new MaskPTL());
    SnapApp.getDefault().getSelectionSupport(Product.class).addHandler((oldValue, newValue) -> updateMaskForm(getSelectedProductSceneView()));
    maskForm.updateState();
    setDisplayName(getTitle());
    add(maskForm.createContentPanel(), BorderLayout.CENTER);
}
 
Example 11
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 12
Source File: ChartPagePanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private JPanel createTopPanel() {
    refreshButton = ToolButtonFactory.createButton(
            UIUtils.loadImageIcon("icons/ViewRefresh22.png"),
            false);
    refreshButton.setToolTipText("Refresh View");
    refreshButton.setName("refreshButton");
    refreshButton.addActionListener(e -> {
        updateChartData();
        refreshButton.setEnabled(false);
    });

    AbstractButton switchToTableButton = ToolButtonFactory.createButton(
            UIUtils.loadImageIcon("icons/Table24.png"),
            false);
    switchToTableButton.setToolTipText("Switch to Table View");
    switchToTableButton.setName("switchToTableButton");
    switchToTableButton.setEnabled(hasAlternativeView());
    switchToTableButton.addActionListener(e -> showAlternativeView());

    final TableLayout tableLayout = new TableLayout(6);
    tableLayout.setColumnFill(2, TableLayout.Fill.HORIZONTAL);
    tableLayout.setColumnWeightX(2, 1.0);
    tableLayout.setRowPadding(0, new Insets(0, 4, 0, 0));
    JPanel buttonPanel = new JPanel(tableLayout);
    buttonPanel.add(refreshButton);
    tableLayout.setRowPadding(0, new Insets(0, 0, 0, 0));
    buttonPanel.add(switchToTableButton);
    buttonPanel.add(new JPanel());

    return buttonPanel;
}
 
Example 13
Source File: MosaicExpressionsPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private static AbstractButton createButton(final String path, String name) {
    final AbstractButton button = ToolButtonFactory.createButton(UIUtils.loadImageIcon(path), false);
    button.setName(name);
    return button;
}
 
Example 14
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 15
Source File: MaskAction.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
JComponent createComponent() {
    AbstractButton button = ToolButtonFactory.createButton(this, false);
    button.setName((String) getValue("componentName"));
    return button;
}
 
Example 16
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;
    }