Java Code Examples for java.awt.Component#setFocusable()

The following examples show how to use java.awt.Component#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: Toolbar.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Overridden to set focusable to false for any AbstractButton
 * subclasses which are added */
@Override
protected void addImpl(Component c, Object constraints, int idx) {
    //issue 39896, after opening dialog from toolbar button, focus
    //remains on toolbar button.  Does not create an accessibility issue - 
    //all standard toolbar buttons are also available via the keyboard
    if (c instanceof AbstractButton) {
        c.setFocusable(false);
        ((JComponent) c).setOpaque(false);
        if (isMetalLaF) {
            //metal/ocean resets borders, so fix it this way
            ((AbstractButton) c).setBorderPainted(false);
            ((AbstractButton) c).setOpaque(false);
        }
        //This is active for GTK L&F. It should be fixed in JDK
        //but it is not fixed in JDK 6.0.
        if (!isMetalLaF && !isFlatLaF) {
            ((AbstractButton) c).setMargin( emptyInsets );
        }
        if( null != label && c != label ) {
            remove( label );
            label = null;
        }
    } else if( c instanceof JToolBar.Separator ) {
        JToolBar.Separator separator = (JToolBar.Separator)c;
        if (getOrientation() == VERTICAL) {
            separator.setOrientation(JSeparator.HORIZONTAL);
        } else {
            separator.setOrientation(JSeparator.VERTICAL);
        }
    }
    
    super.addImpl (c, constraints, idx);
}
 
Example 2
Source File: GenericToolbar.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void doLayout() {
    // #216443 - disabled/invisible/JLabel toolbar components
    //           break left/right arrow focus traversal
    for (Component component : getComponents())
        component.setFocusable(isFocusableComponent(component));
    super.doLayout();
}
 
Example 3
Source File: GenericToolbar.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public void doLayout() {
    // #216443 - disabled/invisible/JLabel toolbar components
    //           break left/right arrow focus traversal
    for (Component component : getComponents())
        component.setFocusable(isFocusableComponent(component));
    super.doLayout();
}
 
Example 4
Source File: DownloadDialogPanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private void doSetStyle(JPanel panel) {
    synchronized (panel.getTreeLock()) {
        for (Component c : panel.getComponents()) {
            if (c instanceof JPanel) {
                doSetStyle((JPanel) c);
            }
            c.setFocusable(false);
        }
        if (this != panel) {
            panel.setOpaque(false);
        }
    }
}
 
Example 5
Source File: JPrincipalApp.java    From nordpos with GNU General Public License v3.0 5 votes vote down vote up
private void addAction(Action act) {

            if (m_appuser.hasPermission((String) act.getValue(AppUserView.ACTION_TASKNAME))) {
                // add the action
                Component c = taskGroup.add(act);
                c.applyComponentOrientation(getComponentOrientation());
                c.setFocusable(false);

                taskGroup.setVisible(true);

                if (m_actionfirst == null) {
                    m_actionfirst = act;
                }
            }
        }