Java Code Examples for java.awt.Component#isFocusable()
The following examples show how to use
java.awt.Component#isFocusable() .
These examples are extracted from open source projects.
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 Project: jdk1.8-source-analysis File: LegacyGlueFocusTraversalPolicy.java License: Apache License 2.0 | 6 votes |
private boolean accept(Component aComponent) { if (!(aComponent.isVisible() && aComponent.isDisplayable() && aComponent.isFocusable() && aComponent.isEnabled())) { return false; } // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not. if (!(aComponent instanceof Window)) { for (Container enableTest = aComponent.getParent(); enableTest != null; enableTest = enableTest.getParent()) { if (!(enableTest.isEnabled() || enableTest.isLightweight())) { return false; } if (enableTest instanceof Window) { break; } } } return true; }
Example 2
Source Project: dragonwell8_jdk File: LegacyGlueFocusTraversalPolicy.java License: GNU General Public License v2.0 | 6 votes |
private boolean accept(Component aComponent) { if (!(aComponent.isVisible() && aComponent.isDisplayable() && aComponent.isFocusable() && aComponent.isEnabled())) { return false; } // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not. if (!(aComponent instanceof Window)) { for (Container enableTest = aComponent.getParent(); enableTest != null; enableTest = enableTest.getParent()) { if (!(enableTest.isEnabled() || enableTest.isLightweight())) { return false; } if (enableTest instanceof Window) { break; } } } return true; }
Example 3
Source Project: TencentKona-8 File: LegacyGlueFocusTraversalPolicy.java License: GNU General Public License v2.0 | 6 votes |
private boolean accept(Component aComponent) { if (!(aComponent.isVisible() && aComponent.isDisplayable() && aComponent.isFocusable() && aComponent.isEnabled())) { return false; } // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not. if (!(aComponent instanceof Window)) { for (Container enableTest = aComponent.getParent(); enableTest != null; enableTest = enableTest.getParent()) { if (!(enableTest.isEnabled() || enableTest.isLightweight())) { return false; } if (enableTest instanceof Window) { break; } } } return true; }
Example 4
Source Project: JDKSourceCode1.8 File: LegacyGlueFocusTraversalPolicy.java License: MIT License | 6 votes |
private boolean accept(Component aComponent) { if (!(aComponent.isVisible() && aComponent.isDisplayable() && aComponent.isFocusable() && aComponent.isEnabled())) { return false; } // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not. if (!(aComponent instanceof Window)) { for (Container enableTest = aComponent.getParent(); enableTest != null; enableTest = enableTest.getParent()) { if (!(enableTest.isEnabled() || enableTest.isLightweight())) { return false; } if (enableTest instanceof Window) { break; } } } return true; }
Example 5
Source Project: openjdk-jdk8u File: LegacyGlueFocusTraversalPolicy.java License: GNU General Public License v2.0 | 6 votes |
private boolean accept(Component aComponent) { if (!(aComponent.isVisible() && aComponent.isDisplayable() && aComponent.isFocusable() && aComponent.isEnabled())) { return false; } // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not. if (!(aComponent instanceof Window)) { for (Container enableTest = aComponent.getParent(); enableTest != null; enableTest = enableTest.getParent()) { if (!(enableTest.isEnabled() || enableTest.isLightweight())) { return false; } if (enableTest instanceof Window) { break; } } } return true; }
Example 6
Source Project: jdk8u_jdk File: LegacyGlueFocusTraversalPolicy.java License: GNU General Public License v2.0 | 6 votes |
private boolean accept(Component aComponent) { if (!(aComponent.isVisible() && aComponent.isDisplayable() && aComponent.isFocusable() && aComponent.isEnabled())) { return false; } // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not. if (!(aComponent instanceof Window)) { for (Container enableTest = aComponent.getParent(); enableTest != null; enableTest = enableTest.getParent()) { if (!(enableTest.isEnabled() || enableTest.isLightweight())) { return false; } if (enableTest instanceof Window) { break; } } } return true; }
Example 7
Source Project: Bytecoder File: LegacyGlueFocusTraversalPolicy.java License: Apache License 2.0 | 6 votes |
private boolean accept(Component aComponent) { if (!(aComponent.isVisible() && aComponent.isDisplayable() && aComponent.isFocusable() && aComponent.isEnabled())) { return false; } // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not. if (!(aComponent instanceof Window)) { for (Container enableTest = aComponent.getParent(); enableTest != null; enableTest = enableTest.getParent()) { if (!(enableTest.isEnabled() || enableTest.isLightweight())) { return false; } if (enableTest instanceof Window) { break; } } } return true; }
Example 8
Source Project: jdk8u-jdk File: LegacyGlueFocusTraversalPolicy.java License: GNU General Public License v2.0 | 6 votes |
private boolean accept(Component aComponent) { if (!(aComponent.isVisible() && aComponent.isDisplayable() && aComponent.isFocusable() && aComponent.isEnabled())) { return false; } // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not. if (!(aComponent instanceof Window)) { for (Container enableTest = aComponent.getParent(); enableTest != null; enableTest = enableTest.getParent()) { if (!(enableTest.isEnabled() || enableTest.isLightweight())) { return false; } if (enableTest instanceof Window) { break; } } } return true; }
Example 9
Source Project: Java8CN File: LegacyGlueFocusTraversalPolicy.java License: Apache License 2.0 | 6 votes |
private boolean accept(Component aComponent) { if (!(aComponent.isVisible() && aComponent.isDisplayable() && aComponent.isFocusable() && aComponent.isEnabled())) { return false; } // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not. if (!(aComponent instanceof Window)) { for (Container enableTest = aComponent.getParent(); enableTest != null; enableTest = enableTest.getParent()) { if (!(enableTest.isEnabled() || enableTest.isLightweight())) { return false; } if (enableTest instanceof Window) { break; } } } return true; }
Example 10
Source Project: jdk8u-jdk File: LegacyGlueFocusTraversalPolicy.java License: GNU General Public License v2.0 | 6 votes |
private boolean accept(Component aComponent) { if (!(aComponent.isVisible() && aComponent.isDisplayable() && aComponent.isFocusable() && aComponent.isEnabled())) { return false; } // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not. if (!(aComponent instanceof Window)) { for (Container enableTest = aComponent.getParent(); enableTest != null; enableTest = enableTest.getParent()) { if (!(enableTest.isEnabled() || enableTest.isLightweight())) { return false; } if (enableTest instanceof Window) { break; } } } return true; }
Example 11
Source Project: openjdk-8-source File: LegacyGlueFocusTraversalPolicy.java License: GNU General Public License v2.0 | 6 votes |
private boolean accept(Component aComponent) { if (!(aComponent.isVisible() && aComponent.isDisplayable() && aComponent.isFocusable() && aComponent.isEnabled())) { return false; } // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not. if (!(aComponent instanceof Window)) { for (Container enableTest = aComponent.getParent(); enableTest != null; enableTest = enableTest.getParent()) { if (!(enableTest.isEnabled() || enableTest.isLightweight())) { return false; } if (enableTest instanceof Window) { break; } } } return true; }
Example 12
Source Project: marathonv5 File: EventQueueWait.java License: Apache License 2.0 | 5 votes |
private static void generateFocusEvents(Component c) { if (c == focusComponent || !c.isFocusable()) { return; } if (focusComponent != null) { dispatchEvent(new FocusEvent(focusComponent, FocusEvent.FOCUS_LOST, false, c)); } dispatchEvent(new FocusEvent(c, FocusEvent.FOCUS_GAINED, false, focusComponent)); }
Example 13
Source Project: iBioSim File: CloseTabPaneUI.java License: Apache License 2.0 | 5 votes |
boolean requestMyFocusForVisibleComponent() { Component visibleComponent = getVisibleComponent(); if (visibleComponent.isFocusable()) { visibleComponent.requestFocus(); return true; } else if (visibleComponent instanceof JComponent) { if (((JComponent) visibleComponent).requestFocusInWindow()) { return true; } } return false; }
Example 14
Source Project: netbeans File: OutlineView.java License: Apache License 2.0 | 5 votes |
@Override protected void processComponentKeyEvent(KeyEvent e) { Component editorComponent = getEditorComponent(); if (editorComponent != null && editorComponent.isFocusable()) { // The event should go to the editor component editorComponent.requestFocusInWindow(); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e); } else { super.processComponentKeyEvent(e); } }
Example 15
Source Project: CodenameOne File: BasicOutlookBarUI.java License: GNU General Public License v2.0 | 5 votes |
protected boolean requestFocusForVisibleComponent0() { Component visibleComponent = getVisibleComponent(); if (visibleComponent.isFocusable()) { visibleComponent.requestFocus(); return true; } else if (visibleComponent instanceof JComponent) { if (((JComponent)visibleComponent).requestDefaultFocus()) { return true; } } return false; }
Example 16
Source Project: FlatLaf File: FlatInspector.java License: Apache License 2.0 | 4 votes |
private String buildToolTipText( Component c ) { String name = c.getClass().getName(); name = name.substring( name.lastIndexOf( '.' ) + 1 ); String text = "Class: " + name + " (" + c.getClass().getPackage().getName() + ")\n" + "Size: " + c.getWidth() + ',' + c.getHeight() + " @ " + c.getX() + ',' + c.getY() + '\n'; if( c instanceof Container ) text += "Insets: " + toString( ((Container)c).getInsets() ) + '\n'; Insets margin = null; if( c instanceof AbstractButton ) margin = ((AbstractButton) c).getMargin(); else if( c instanceof JTextComponent ) margin = ((JTextComponent) c).getMargin(); else if( c instanceof JMenuBar ) margin = ((JMenuBar) c).getMargin(); else if( c instanceof JToolBar ) margin = ((JToolBar) c).getMargin(); if( margin != null ) text += "Margin: " + toString( margin ) + '\n'; Dimension prefSize = c.getPreferredSize(); Dimension minSize = c.getMinimumSize(); Dimension maxSize = c.getMaximumSize(); text += "Pref size: " + prefSize.width + ',' + prefSize.height + '\n' + "Min size: " + minSize.width + ',' + minSize.height + '\n' + "Max size: " + maxSize.width + ',' + maxSize.height + '\n'; if( c instanceof JComponent ) text += "Border: " + toString( ((JComponent)c).getBorder() ) + '\n'; text += "Background: " + toString( c.getBackground() ) + '\n' + "Foreground: " + toString( c.getForeground() ) + '\n' + "Font: " + toString( c.getFont() ) + '\n'; if( c instanceof JComponent ) { try { Field f = JComponent.class.getDeclaredField( "ui" ); f.setAccessible( true ); Object ui = f.get( c ); text += "UI: " + (ui != null ? ui.getClass().getName() : "null") + '\n'; } catch( NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex ) { // ignore } } if( c instanceof Container ) { LayoutManager layout = ((Container)c).getLayout(); if( layout != null ) text += "Layout: " + layout.getClass().getName() + '\n'; } text += "Enabled: " + c.isEnabled() + '\n'; text += "Opaque: " + c.isOpaque() + (c instanceof JComponent && FlatUIUtils.hasOpaqueBeenExplicitlySet( (JComponent) c ) ? " EXPLICIT" : "") + '\n'; if( c instanceof AbstractButton ) text += "ContentAreaFilled: " + ((AbstractButton)c).isContentAreaFilled() + '\n'; text += "Focusable: " + c.isFocusable() + '\n'; text += "Left-to-right: " + c.getComponentOrientation().isLeftToRight() + '\n'; text += "Parent: " + (c.getParent() != null ? c.getParent().getClass().getName() : "null"); if( inspectParentLevel > 0 ) text += "\n\nParent level: " + inspectParentLevel; if( inspectParentLevel > 0 ) text += "\n(press Ctrl/Shift to increase/decrease level)"; else text += "\n\n(press Ctrl key to inspect parent)"; return text; }
Example 17
Source Project: visualvm File: ProfilerPopup.java License: GNU General Public License v2.0 | 4 votes |
private static boolean focusable(Component c) { if (c instanceof JLabel || c instanceof Box.Filler) return false; return c.isVisible() && c.isEnabled() && c.isFocusable(); }
Example 18
Source Project: netbeans File: ProfilerPopup.java License: Apache License 2.0 | 4 votes |
private static boolean focusable(Component c) { if (c instanceof JLabel || c instanceof Box.Filler) return false; return c.isVisible() && c.isEnabled() && c.isFocusable(); }
Example 19
Source Project: PolyGlot File: PFocusTraversalPolicy.java License: MIT License | 4 votes |
@Override protected boolean accept(final Component c) { return c.isFocusable() && super.accept(c); }
Example 20
Source Project: visualvm File: ProfilerToolbar.java License: GNU General Public License v2.0 | 4 votes |
protected boolean focusable(Component c) { return c.isVisible() && c.isEnabled() && c.isFocusable(); }