下面列出了javax.swing.AbstractButton#setFocusable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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));
}
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
}
}
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);
}
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);
}
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;
}
private AbstractButton addButton(AbstractButton button)
{
button.setFocusable(false);
add(button);
return button;
}
/** Overridden to not call super.installDefaults() and only set the button
* to be non-focusable */
@Override
public void installDefaults (AbstractButton b) {
b.setFocusable (false);
}
private static void processButton(AbstractButton button) {
removeButtonContentAreaAndBorder(button);
button.setMargin(BUTTON_INSETS);
button.addMouseListener(sharedMouseListener);
button.setFocusable(false);
}