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

The following examples show how to use javax.swing.AbstractButton#setFocusable() . 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: FlatFileChooserUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
private void patchUI( JFileChooser fc ) {
	// turn top-right buttons into toolbar buttons
	Component topPanel = fc.getComponent( 0 );
	if( (topPanel instanceof JPanel) &&
		(((JPanel)topPanel).getLayout() instanceof BorderLayout) )
	{
		Component topButtonPanel = ((JPanel)topPanel).getComponent( 0 );
		if( (topButtonPanel instanceof JPanel) &&
			(((JPanel)topButtonPanel).getLayout() instanceof BoxLayout) )
		{
			Insets margin = UIManager.getInsets( "Button.margin" );
			Component[] comps = ((JPanel)topButtonPanel).getComponents();
			for( int i = comps.length - 1; i >= 0; i-- ) {
				Component c = comps[i];
				if( c instanceof JButton || c instanceof JToggleButton ) {
					AbstractButton b = (AbstractButton)c;
					b.putClientProperty( FlatClientProperties.BUTTON_TYPE,
						FlatClientProperties.BUTTON_TYPE_TOOLBAR_BUTTON );
					b.setMargin( margin );
					b.setFocusable( false );
				} else if( c instanceof Box.Filler )
					((JPanel)topButtonPanel).remove( i );
			}
		}
	}

	// increase maximum row count of directory combo box popup list
	try {
		Component directoryComboBox =  ((JPanel)topPanel).getComponent( 2 );
		if( directoryComboBox instanceof JComboBox ) {
			int maximumRowCount = UIManager.getInt( "ComboBox.maximumRowCount" );
			if( maximumRowCount > 0 )
				((JComboBox<?>)directoryComboBox).setMaximumRowCount( maximumRowCount );
		}
	} catch( ArrayIndexOutOfBoundsException ex ) {
		// ignore
	}
}
 
Example 3
Source File: NbEditorToolBar.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void processButton(AbstractButton button) {
    removeButtonContentAreaAndBorder(button);
    button.setMargin(BUTTON_INSETS);
    if (button instanceof AbstractButton) {
        button.addMouseListener(sharedMouseListener);
    }
    //fix of issue #69642. Focus shouldn't stay in toolbar
    button.setFocusable(false);
}
 
Example 4
Source File: DataViewUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void processButton(AbstractButton button) {
    button.setContentAreaFilled(false);
    button.setBorderPainted(false);
    button.setMargin(BUTTON_INSETS);
    if (button instanceof AbstractButton) {
        button.addMouseListener(sharedMouseListener);
    }
    //Focus shouldn't stay in toolbar
    button.setFocusable(false);
}
 
Example 5
Source File: ProductSceneView.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private AdjustableViewScrollPane createScrollPane() {
    AbstractButton zoomAllButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomAll13.gif"),
            false);
    zoomAllButton.setFocusable(false);
    zoomAllButton.setFocusPainted(false);
    zoomAllButton.addActionListener(e -> getLayerCanvas().zoomAll());

    AdjustableViewScrollPane scrollPane = new AdjustableViewScrollPane(layerCanvas);
    // todo - use sceneImage.getConfiguration() (nf, 18.09.2008)
    scrollPane.setBackground(DEFAULT_IMAGE_BACKGROUND_COLOR);
    scrollPane.setCornerComponent(zoomAllButton);
    return scrollPane;
}
 
Example 6
Source File: GoGuiToolBar.java    From FancyBing with GNU General Public License v3.0 4 votes vote down vote up
private AbstractButton addButton(AbstractButton button)
{
    button.setFocusable(false);
    add(button);
    return button;
}
 
Example 7
Source File: SlidingTabDisplayerButtonUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Overridden to not call super.installDefaults() and only set the button
 * to be non-focusable */
@Override
public void installDefaults (AbstractButton b) {
    b.setFocusable (false);
}
 
Example 8
Source File: SearchButton.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void processButton(AbstractButton button) {
    removeButtonContentAreaAndBorder(button);
    button.setMargin(BUTTON_INSETS);
    button.addMouseListener(sharedMouseListener);
    button.setFocusable(false);
}