Java Code Examples for java.awt.Component#addFocusListener()
The following examples show how to use
java.awt.Component#addFocusListener() .
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: EditableLabel.java From jace with GNU General Public License v2.0 | 6 votes |
public EditableLabel(JLabel label, Component edit, int width, int horizontalPadding, int verticalPadding, Object owner, String property) { ownerObject = owner; this.width = width; objectProperty = property; addMouseListener(this); edit.addFocusListener(this); addFocusListener(this); layout = new CardLayout(horizontalPadding, verticalPadding); setLayout(layout); add(label, cards.label.toString()); add(edit, cards.edit.toString()); labelComponent = label; editComponent = edit; deactivateEdit(); setBackground(UserInterface.Theme.background.color); label.setForeground(UserInterface.Theme.foreground.color); label.setOpaque(false); edit.setBackground(UserInterface.Theme.backgroundEdit.color); edit.setForeground(UserInterface.Theme.foregroundEdit.color); edit.setFocusTraversalKeysEnabled(false); edit.addKeyListener(NAV_LISTENER); label.addKeyListener(NAV_LISTENER); this.addKeyListener(NAV_LISTENER); }
Example 2
Source File: WrapperInplaceEditor.java From netbeans with Apache License 2.0 | 6 votes |
/** Connect to the underlying property editor. Will add the component * to this WrapperInplaceEditor's component hierarchy and start listening * on it for action and focus events */ public void connect(java.beans.PropertyEditor pe, PropertyEnv env) { if (legacy != null) { //Should never be called twice without a clear(), but just in case clear(); } if (pe != enh) { enh = (EnhancedPropertyEditor) pe; } Component comp = getLegacyInplaceEditor(); add(comp, BorderLayout.CENTER); listenerAdded = tryAddActionListener(comp); comp.addFocusListener(this); }
Example 3
Source File: BEToolBarUI.java From beautyeye with Apache License 2.0 | 6 votes |
public void componentAdded(ContainerEvent evt) { Component c = evt.getChild(); if (toolBarFocusListener != null) { c.addFocusListener(toolBarFocusListener); } if (isRolloverBorders()) { setBorderToRollover(c); } else { setBorderToNonRollover(c); } //## Bug FIX:Issue 51(https://code.google.com/p/beautyeye/issues/detail?id=51) //* 由Jack Jiang201210-12日注释掉:它样做将导致各种放入的组 //* 件(如文本框)等都将透明,从而不绘制该 组件的背景,那就错误了哦 //* 其实以下代码原本是为了解决放入到JToggleButton的白色背景问题,现在它 //* 已经在BEToolgleButtonUI里解决了,此处就不需要了,也不应该要! // //* 只有它一行是由jb2011加的 // if(c instanceof JComponent) // ((JComponent)c).setOpaque(false); }
Example 4
Source File: SeaGlassScrollPaneUI.java From seaglass with Apache License 2.0 | 5 votes |
protected void installListeners(JScrollPane c) { vsbChangeListener = createVSBChangeListener(); vsbPropertyChangeListener = createVSBPropertyChangeListener(); hsbChangeListener = createHSBChangeListener(); hsbPropertyChangeListener = createHSBPropertyChangeListener(); viewportChangeListener = createViewportChangeListener(); spPropertyChangeListener = createPropertyChangeListener(); JViewport viewport = scrollpane.getViewport(); JScrollBar vsb = scrollpane.getVerticalScrollBar(); JScrollBar hsb = scrollpane.getHorizontalScrollBar(); if (viewport != null) { viewport.addChangeListener(viewportChangeListener); } if (vsb != null) { vsb.getModel().addChangeListener(vsbChangeListener); vsb.addPropertyChangeListener(vsbPropertyChangeListener); } if (hsb != null) { hsb.getModel().addChangeListener(hsbChangeListener); hsb.addPropertyChangeListener(hsbPropertyChangeListener); } scrollpane.addPropertyChangeListener(spPropertyChangeListener); mouseScrollListener = createMouseWheelListener(); scrollpane.addMouseWheelListener(mouseScrollListener); // From SynthScrollPaneUI. c.addPropertyChangeListener(this); if (UIManager.getBoolean("ScrollPane.useChildTextComponentFocus")) { viewportViewFocusHandler = new ViewportViewFocusHandler(); c.getViewport().addContainerListener(viewportViewFocusHandler); Component view = c.getViewport().getView(); if (view instanceof JTextComponent) { view.addFocusListener(viewportViewFocusHandler); } } }
Example 5
Source File: ParameterTupelCellEditor.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
private void constructPanel(String[] values) { // constructing editors editors = new PropertyValueCellEditor[types.length]; for (int i = 0; i < types.length; i++) { editors[i] = PropertyPanel.instantiateValueCellEditor(types[i], operator); } // building panel panel = new JPanel(); panel.setFocusable(true); panel.setLayout(new GridLayout(1, editors.length)); for (int i = 0; i < types.length; i++) { Component editorComponent = editors[i].getTableCellEditorComponent(null, values[i], false, 0, 0); if (editorComponent instanceof JComboBox) { if (((JComboBox<?>) editorComponent).isEditable()) { ComboBoxEditor editor = ((JComboBox<?>) editorComponent).getEditor(); if (editor instanceof BasicComboBoxEditor) { editor.getEditorComponent().addFocusListener(focusListener); } } else { editorComponent.addFocusListener(focusListener); } } else if (editorComponent instanceof JPanel) { JPanel editorPanel = (JPanel) editorComponent; Component[] components = editorPanel.getComponents(); for (Component comp : components) { comp.addFocusListener(focusListener); } } else { editorComponent.addFocusListener(focusListener); } panel.add(editorComponent); panel.addFocusListener(focusListener); } }
Example 6
Source File: BasicLizziePaneUI.java From lizzie with GNU General Public License v3.0 | 5 votes |
public void installListeners() { dockingListener = createDockingListener(); if (dockingListener != null) { lizziePane.addMouseMotionListener(dockingListener); lizziePane.addMouseListener(dockingListener); } propertyListener = createPropertyListener(); // added in setFloating if (propertyListener != null) { lizziePane.addPropertyChangeListener(propertyListener); } lizziePaneContListener = createLizziePaneContListener(); if (lizziePaneContListener != null) { lizziePane.addContainerListener(lizziePaneContListener); } lizziePaneFocusListener = createLizziePaneFocusListener(); if (lizziePaneFocusListener != null) { // Put focus listener on all components in lizziePane Component[] components = lizziePane.getComponents(); for (Component component : components) { component.addFocusListener(lizziePaneFocusListener); } } }
Example 7
Source File: BasicLizziePaneUI.java From lizzie with GNU General Public License v3.0 | 5 votes |
public void componentAdded(ContainerEvent evt) { Component c = evt.getChild(); if (lizziePaneFocusListener != null) { c.addFocusListener(lizziePaneFocusListener); } }
Example 8
Source File: JWindowToolBarUI.java From pdfxtk with Apache License 2.0 | 5 votes |
public void componentAdded( ContainerEvent e ) { Component c = e.getChild(); if ( toolBarFocusListener != null ) { c.addFocusListener( toolBarFocusListener ); } }
Example 9
Source File: ExtTestCase.java From netbeans with Apache License 2.0 | 5 votes |
public WaitFocus(Component c) throws Exception { c.addFocusListener(this); requestFocus(c); if (!SwingUtilities.isEventDispatchThread()) { synchronized (this) { try { wait(5000); } catch (Exception e) { e.printStackTrace(); } } } }
Example 10
Source File: UIUtils.java From netbeans with Apache License 2.0 | 5 votes |
private static void keepFocusedComponentVisible(Component component, FocusListener l) { component.removeFocusListener(l); // Making sure that it is not added twice component.addFocusListener(l); if (component instanceof Container) { for (Component subComponent : ((Container)component).getComponents()) { keepFocusedComponentVisible(subComponent, l); } } }
Example 11
Source File: FlatScrollPaneUI.java From FlatLaf with Apache License 2.0 | 5 votes |
private void addViewportListeners( JViewport viewport ) { if( viewport == null ) return; viewport.addContainerListener( getHandler() ); Component view = viewport.getView(); if( view != null ) view.addFocusListener( getHandler() ); }
Example 12
Source File: SplayedLayout.java From pumpernickel with MIT License | 5 votes |
private void addListeners(Component c) { if (!Arrays.asList(c.getMouseListeners()).contains(mouseListener)) c.addMouseListener(mouseListener); if (!Arrays.asList(c.getFocusListeners()).contains(focusListener)) c.addFocusListener(focusListener); if (c instanceof Container) { Container c2 = (Container) c; for (int a = 0; a < c2.getComponentCount(); a++) { addListeners(c2.getComponent(a)); } } }
Example 13
Source File: Util.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
void setListener(Component comp) { comp.addFocusListener(this); }
Example 14
Source File: Util.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
void setListener(Component comp) { comp.addFocusListener(this); }
Example 15
Source File: Util.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
void setListener(Component comp) { comp.addFocusListener(this); }
Example 16
Source File: Util.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
void setListener(Component comp) { comp.addFocusListener(this); }
Example 17
Source File: Util.java From hottub with GNU General Public License v2.0 | 4 votes |
void setListener(Component comp) { comp.addFocusListener(this); }
Example 18
Source File: Util.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
void setListener(Component comp) { comp.addFocusListener(this); }
Example 19
Source File: Util.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
void setListener(Component comp) { comp.addFocusListener(this); }
Example 20
Source File: Util.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
void setListener(Component comp) { comp.addFocusListener(this); }