Java Code Examples for java.awt.event.FocusListener

The following are top voted examples for showing how to use java.awt.event.FocusListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: A11YUtil.java   View source code 6 votes vote down vote up
/**
 * Get universal Focus listener suitable for decsription JTextFields only.
 * It provides screen reades support for read only enabled descriptions.
 */
public static synchronized FocusListener getA11YJTextFieldSupport() {

    if (flis == null) {
        flis = new java.awt.event.FocusListener() {
            public void focusGained(java.awt.event.FocusEvent e) {
                if (e.getComponent() instanceof javax.swing.JTextField) {
                    ((javax.swing.JTextField)e.getComponent()).selectAll();
                }
            }
            public void focusLost(java.awt.event.FocusEvent e) {
                if (e.getComponent() instanceof javax.swing.JTextField) {
                    ((javax.swing.JTextField)e.getComponent()).select(1,1);
                }
            }
        };
    }
    return flis;
}
 
Example 2
Project: incubator-netbeans   File: WeakListenerImpl.java   View source code 6 votes vote down vote up
/** Delegates to the original listener.
*/
@Override public void focusLost(FocusEvent ev) {
    FocusListener l = (FocusListener) super.get(ev);

    if (l != null) {
        l.focusLost(ev);
    }
}
 
Example 3
Project: jdk8u-jdk   File: bug4624207.java   View source code 6 votes vote down vote up
private static void createAndShowGUI() {
    tab = new JTabbedPane();
    tab.add("Tab1", new JButton("Button1"));
    tab.add("Tab2", new JButton("Button2"));
    tab.setMnemonicAt(0, KeyEvent.VK_T);
    tab.setMnemonicAt(1, KeyEvent.VK_B);

    JFrame frame = new JFrame();
    frame.getContentPane().add(tab, BorderLayout.CENTER);
    txtField = new JTextField();
    frame.getContentPane().add(txtField, BorderLayout.NORTH);
    listener = new bug4624207();
    txtField.addFocusListener((FocusListener) listener);
    frame.pack();
    frame.setVisible(true);
}
 
Example 4
Project: openjdk-jdk10   File: bug4624207.java   View source code 6 votes vote down vote up
private static void createAndShowGUI() {
    tab = new JTabbedPane();
    tab.add("Tab1", new JButton("Button1"));
    tab.add("Tab2", new JButton("Button2"));
    tab.setMnemonicAt(0, KeyEvent.VK_T);
    tab.setMnemonicAt(1, KeyEvent.VK_B);

    JFrame frame = new JFrame();
    frame.getContentPane().add(tab, BorderLayout.CENTER);
    txtField = new JTextField();
    frame.getContentPane().add(txtField, BorderLayout.NORTH);
    listener = new bug4624207();
    txtField.addFocusListener((FocusListener) listener);
    frame.pack();
    frame.setVisible(true);
}
 
Example 5
Project: openjdk9   File: bug4624207.java   View source code 6 votes vote down vote up
private static void createAndShowGUI() {
    tab = new JTabbedPane();
    tab.add("Tab1", new JButton("Button1"));
    tab.add("Tab2", new JButton("Button2"));
    tab.setMnemonicAt(0, KeyEvent.VK_T);
    tab.setMnemonicAt(1, KeyEvent.VK_B);

    JFrame frame = new JFrame();
    frame.getContentPane().add(tab, BorderLayout.CENTER);
    txtField = new JTextField();
    frame.getContentPane().add(txtField, BorderLayout.NORTH);
    listener = new bug4624207();
    txtField.addFocusListener((FocusListener) listener);
    frame.pack();
    frame.setVisible(true);
}
 
Example 6
Project: jdk8u_jdk   File: bug4624207.java   View source code 6 votes vote down vote up
private static void createAndShowGUI() {
    tab = new JTabbedPane();
    tab.add("Tab1", new JButton("Button1"));
    tab.add("Tab2", new JButton("Button2"));
    tab.setMnemonicAt(0, KeyEvent.VK_T);
    tab.setMnemonicAt(1, KeyEvent.VK_B);

    JFrame frame = new JFrame();
    frame.getContentPane().add(tab, BorderLayout.CENTER);
    txtField = new JTextField();
    frame.getContentPane().add(txtField, BorderLayout.NORTH);
    listener = new bug4624207();
    txtField.addFocusListener((FocusListener) listener);
    frame.pack();
    frame.setVisible(true);
}
 
Example 7
Project: lookaside_java-1.8.0-openjdk   File: bug4624207.java   View source code 6 votes vote down vote up
private static void createAndShowGUI() {
    tab = new JTabbedPane();
    tab.add("Tab1", new JButton("Button1"));
    tab.add("Tab2", new JButton("Button2"));
    tab.setMnemonicAt(0, KeyEvent.VK_T);
    tab.setMnemonicAt(1, KeyEvent.VK_B);

    JFrame frame = new JFrame();
    frame.getContentPane().add(tab, BorderLayout.CENTER);
    txtField = new JTextField();
    frame.getContentPane().add(txtField, BorderLayout.NORTH);
    listener = new bug4624207();
    txtField.addFocusListener((FocusListener) listener);
    frame.pack();
    frame.setVisible(true);
}
 
Example 8
Project: polygene-java   File: BoundAssociation.java   View source code 6 votes vote down vote up
public void use( Association<T> actualAssociation )
{
    actual = actualAssociation;
    T value = null;
    if( actualAssociation != null )
    {
        value = actualAssociation.get();
    }
    stateModel.use( value );
    for( JComponent component : components )
    {
        SwingAdapter adapter = adapters.get( component.getClass() );
        adapter.fromAssociationToSwing( component, actualAssociation );
        for( FocusListener listener : component.getFocusListeners() )
        {
            if( AssociationFocusLostListener.class.isInstance( listener ) )
            {
                ( (AssociationFocusLostListener) listener ).use( adapter, actual );
            }
        }
    }
}
 
Example 9
Project: polygene-java   File: BoundProperty.java   View source code 6 votes vote down vote up
public void use( Property<T> actualProperty )
{
    T value = null;
    if( actualProperty != null )
    {
        value = actualProperty.get();
    }
    stateModel.use( value );
    for( JComponent component : components )
    {
        SwingAdapter adapter = adapters.get( component.getClass() );
        adapter.fromPropertyToSwing( component, actualProperty );
        for( FocusListener listener : component.getFocusListeners() )
        {
            if( PropertyFocusLostListener.class.isInstance( listener ) )
            {
                ( (PropertyFocusLostListener) listener ).use( adapter, actualProperty );
            }
        }
    }
}
 
Example 10
Project: swingx   File: AutoCompleteDecoratorTest.java   View source code 6 votes vote down vote up
/**
 * SwingX Issue #299.
 */
@Test
public void testUndecorateTextComponent() {
    JTextField textField = new JTextField();
    
    AutoCompleteDecorator.decorate(textField, Collections.emptyList(), true);
    
    AutoCompleteDecorator.undecorate(textField);
    
    assertThat(textField.getInputMap(), is(not(instanceOf(AutoComplete.InputMap.class))));
    assertThat(textField.getActionMap().get("nonstrict-backspace"), is(nullValue()));
    for (FocusListener l : textField.getFocusListeners()) {
        assertThat(l, is(not(instanceOf(AutoComplete.FocusAdapter.class))));
    }
    assertThat(textField.getDocument(), is(not(instanceOf(AutoCompleteDocument.class))));
}
 
Example 11
Project: mindraider   File: RichTextAnnotationRenderer.java   View source code 6 votes vote down vote up
public void init() {
    EditorAndViewerMouseListener editorAndViewerMouseListener 
        = new EditorAndViewerMouseListener(this);
    RichTextEditorKeyListener richTextEditorKeyListener 
        = new RichTextEditorKeyListener(new EditorKeyListener(getConceptPanel(),this), this);

    super.init(
            new RichTextToHtmlTransformer(),
            richTextEditorKeyListener,
            new ViewerKeyListener(getConceptPanel(),this),
            new EditorFocusListener(getConceptPanel()),
            (FocusListener)null,
            editorAndViewerMouseListener,
            editorAndViewerMouseListener,
            new TextAnnotationToolbar(this));
}
 
Example 12
Project: power-matchmaker   File: MungePen.java   View source code 6 votes vote down vote up
/**
 * Removes all listeners associated with the given Component. This is useful when removing to to make sure
 * it does not stick around.
 */
public static void removeAllListeners(Component com) {
	for (FocusListener fl : com.getFocusListeners()) {
		com.removeFocusListener(fl);
	}
	
	for (MouseListener ml : com.getMouseListeners()) {
		com.removeMouseListener(ml);
	}
	
	for (MouseMotionListener mml : com.getMouseMotionListeners()) {
		com.removeMouseMotionListener(mml);
	}
	
	for (KeyListener kl : com.getKeyListeners()) {
		com.removeKeyListener(kl);
	}
	
	for (ComponentListener cl : com.getComponentListeners()) {
		com.removeComponentListener(cl);
	}
}
 
Example 13
Project: infobip-open-jdk-8   File: bug4624207.java   View source code 6 votes vote down vote up
private static void createAndShowGUI() {
    tab = new JTabbedPane();
    tab.add("Tab1", new JButton("Button1"));
    tab.add("Tab2", new JButton("Button2"));
    tab.setMnemonicAt(0, KeyEvent.VK_T);
    tab.setMnemonicAt(1, KeyEvent.VK_B);

    JFrame frame = new JFrame();
    frame.getContentPane().add(tab, BorderLayout.CENTER);
    txtField = new JTextField();
    frame.getContentPane().add(txtField, BorderLayout.NORTH);
    listener = new bug4624207();
    txtField.addFocusListener((FocusListener) listener);
    frame.pack();
    frame.setVisible(true);
}
 
Example 14
Project: jdk8u-dev-jdk   File: bug4624207.java   View source code 6 votes vote down vote up
private static void createAndShowGUI() {
    tab = new JTabbedPane();
    tab.add("Tab1", new JButton("Button1"));
    tab.add("Tab2", new JButton("Button2"));
    tab.setMnemonicAt(0, KeyEvent.VK_T);
    tab.setMnemonicAt(1, KeyEvent.VK_B);

    JFrame frame = new JFrame();
    frame.getContentPane().add(tab, BorderLayout.CENTER);
    txtField = new JTextField();
    frame.getContentPane().add(txtField, BorderLayout.NORTH);
    listener = new bug4624207();
    txtField.addFocusListener((FocusListener) listener);
    frame.pack();
    frame.setVisible(true);
}
 
Example 15
Project: MP3ToolKit   File: ID3RightPanel.java   View source code 6 votes vote down vote up
/**
 * sets a FocusListener
 * 
 * @param l
 *            the FocusListener
 */
public void setFocusListener(FocusListener l) {
	this.titleTF.addFocusListener(l);
	this.artistTF.addFocusListener(l);
	this.albumArtistTF.addFocusListener(l);
	this.albumTF.addFocusListener(l);
	this.yearTF.addFocusListener(l);
	this.maxTracksTF.addFocusListener(l);
	this.maxCDTF.addFocusListener(l);
	this.commentTF.addFocusListener(l);
	this.composerTF.addFocusListener(l);
	this.origArtistTF.addFocusListener(l);
	this.copyrightTF.addFocusListener(l);
	this.urlTF.addFocusListener(l);
	this.encodedByTF.addFocusListener(l);
	this.trackTF.addFocusListener(l);
	this.cdTF.addFocusListener(l);
	this.publisherTF.addFocusListener(l);
	this.genreCB.addFocusListener(l);
	this.lyricsTA.addFocusListener(l);
}
 
Example 16
Project: cn1   File: Component.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (ComponentListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getComponentListeners();
    } else if (FocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getFocusListeners();
    } else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyBoundsListeners();
    } else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyListeners();
    } else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getInputMethodListeners();
    } else if (KeyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getKeyListeners();
    } else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseWheelListeners();
    } else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseMotionListeners();
    } else if (MouseListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseListeners();
    } else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getPropertyChangeListeners();
    }
    return (T[]) Array.newInstance(listenerType, 0);
}
 
Example 17
Project: cn1   File: TextComponent.java   View source code 6 votes vote down vote up
TextComponent() {
    state = new State();
    editable = true;
    dispatchToIM = true; // had been disabled by createBehavior()
    setFont(new Font("DialogInput", Font.PLAIN, 12)); // QUICK FIX //$NON-NLS-1$
    document = new PlainDocument();
    //        text = new StringBuffer();
    setTextKit(new TextKitImpl());
    rootViewContext = createRootViewContext();
    rootViewContext.getView().append(createView());
    rootViewContext.getView().setSize(w, h);
    caret = createCaret();
    setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    addAWTMouseListener(getMouseHandler());
    addAWTMouseMotionListener(getMotionHandler());
    addAWTFocusListener((FocusListener) caret);
    addAWTKeyListener(new KeyHandler());
    // document handler must be added after caret's listener has been added!
    document.addDocumentListener(new DocumentHandler());
}
 
Example 18
Project: cn1   File: AccessibleAWTComponentTest.java   View source code 6 votes vote down vote up
public final void testAddRemoveFocusListener() {
    assertEquals(0, comp.getFocusListeners().length);
    aComponent.addFocusListener(focusListener);
    FocusListener[] listeners = comp.getFocusListeners();
    assertEquals(1, listeners.length);
    assertSame(focusListener, listeners[0]);
    assertNull(lastFocusEvent);
    comp.processEvent(new FocusEvent(comp, FocusEvent.FOCUS_GAINED));
    assertNotNull("focus listener called", lastFocusEvent);
    lastFocusEvent = null;
    aComponent.removeFocusListener(null);
    listeners = comp.getFocusListeners();
    assertSame(focusListener, listeners[0]);
    comp.processEvent(new FocusEvent(comp, FocusEvent.FOCUS_LOST));
    assertNotNull("focus listener called", lastFocusEvent);
    lastFocusEvent = null;
    aComponent.removeFocusListener(focusListener);
    listeners = comp.getFocusListeners();
    comp.processEvent(new FocusEvent(comp, FocusEvent.FOCUS_LOST, true));
    assertEquals(0, listeners.length);
    assertNull("listener not called", lastFocusEvent);

}
 
Example 19
Project: cn1   File: JComponent_MultithreadedTest.java   View source code 6 votes vote down vote up
protected boolean requestFocusInWindowForComponent(final JComponent c, int maxWaitTime)
        throws Exception {
    FocusListener listener = addFocusListener(c);
    RunnableResulted thread = new RunnableResulted() {
        @Override
        public void run() {
            result = c.requestFocusInWindow();
        }
    };
    SwingUtilities.invokeAndWait(thread);
    if (!thread.result) {
        return false;
    }
    synchronized (listener) {
        listener.wait(maxWaitTime);
    }
    waitForIdle();
    if (!c.isFocusOwner()) {
        fail();
    }
    return true;
}
 
Example 20
Project: cn1   File: JComponent_MultithreadedTest.java   View source code 6 votes vote down vote up
protected boolean requestFocusInWindowForComponent(final JComponent c, final boolean temporarily,
                                                   int maxWaitTime) throws Exception {
    FocusListener listener = addFocusListener(c);
    RunnableResulted thread = new RunnableResulted() {
        @Override
        public void run() {
            result = c.requestFocusInWindow(temporarily);
        }
    };
    SwingUtilities.invokeAndWait(thread);
    if (!thread.result) {
        return false;
    }
    synchronized (listener) {
        listener.wait(maxWaitTime);
    }
    waitForIdle();
    if (!c.isFocusOwner()) {
        fail();
    }
    return true;
}
 
Example 21
Project: cn1   File: JComponent_MultithreadedTest.java   View source code 6 votes vote down vote up
protected void requestFocusForComponent(final JComponent c, final boolean temporarily,
                                        int maxWaitTime) throws Exception {
    FocusListener listener = addFocusListener(c);
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            c.requestFocus(temporarily);
        }
    });

    synchronized (listener) {
        listener.wait(maxWaitTime);
    }
    waitForIdle();
    if (!c.isFocusOwner()) {
        fail();
    }
}
 
Example 22
Project: incubator-netbeans   File: CollapsibleSectionPanel.java   View source code 5 votes vote down vote up
public ActionsBuilder (JPanel panel, FocusListener listener) {
    this.focusListener = listener;
    panel.removeAll();
    GroupLayout layout = (GroupLayout) panel.getLayout();
    horizontalSeqGroup = layout.createSequentialGroup();
    layout.setHorizontalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(horizontalSeqGroup)
    );
    verticalParallelGroup = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(verticalParallelGroup)
    );
}
 
Example 23
Project: incubator-netbeans   File: UIUtils.java   View source code 5 votes vote down vote up
public static void keepFocusedComponentVisible(Component component, JComponent container) {
    FocusListener listener;
    if(component instanceof JComponent ) {
        listener = getNotShowingFieldsFocusListener(container);
    } else {
        listener = getScrollingFocusListener(); // legacy fallback
    }
    keepFocusedComponentVisible(component, listener);
}
 
Example 24
Project: incubator-netbeans   File: UIUtils.java   View source code 5 votes vote down vote up
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 25
Project: incubator-netbeans   File: UIUtils.java   View source code 5 votes vote down vote up
private static FocusListener getNotShowingFieldsFocusListener(JComponent container) {
    String key = "notShowingFieldFocusListener";                            // NOI18N
    Object l = container.getClientProperty(key);
    if (l == null) {
        l = new NotShowingFieldsFocusListener(container);
        container.putClientProperty(key, l);
    }
    return (FocusListener) l;
}
 
Example 26
Project: incubator-netbeans   File: IconPanel.java   View source code 5 votes vote down vote up
public void addFocusListener(FocusListener fl) {
    if (comp != null) {
        comp.addFocusListener(fl);
    } else {
        super.addFocusListener(fl);
    }
}
 
Example 27
Project: incubator-netbeans   File: IconPanel.java   View source code 5 votes vote down vote up
public void removeFocusListener(FocusListener fl) {
    if (comp != null) {
        comp.removeFocusListener(fl);
    } else {
        super.removeFocusListener(fl);
    }
}
 
Example 28
Project: incubator-netbeans   File: ButtonPanel.java   View source code 5 votes vote down vote up
/** Overridden to proxy adds to the custom editor button and the
 * installed component */
public void addFocusListener(FocusListener l) {
    if (comp != null) {
        button.addFocusListener(l);
        comp.addFocusListener(l);
    }
}
 
Example 29
Project: incubator-netbeans   File: ButtonPanel.java   View source code 5 votes vote down vote up
/** Overridden to proxy removes to the custom editor button and the
 * installed component */
public void removeFocusListener(FocusListener l) {
    if (comp != null) {
        button.removeFocusListener(l);
        comp.removeFocusListener(l);
    }
}
 
Example 30
Project: incubator-netbeans   File: WeakListener.java   View source code 5 votes vote down vote up
/** Delegates to the original listener.
*/
public void focusGained(FocusEvent ev) {
    FocusListener l = (FocusListener) super.get(ev);

    if (l != null) {
        l.focusGained(ev);
    }
}
 
Example 31
Project: incubator-netbeans   File: WeakListener.java   View source code 5 votes vote down vote up
/** Delegates to the original listener.
*/
public void focusLost(FocusEvent ev) {
    FocusListener l = (FocusListener) super.get(ev);

    if (l != null) {
        l.focusLost(ev);
    }
}
 
Example 32
Project: incubator-netbeans   File: SectionInnerPanel.java   View source code 5 votes vote down vote up
public synchronized void addFocusListener(FocusListener l) {
    super.addFocusListener(l);
    if (!localFocusListenerInitialized) {
        localFocusListenerInitialized = true;
        Container container = this;
        FocusListener focusListener = localFocusListener;
        addFocusListenerRecursively(container, focusListener);
    }
}
 
Example 33
Project: incubator-netbeans   File: SectionInnerPanel.java   View source code 5 votes vote down vote up
private void addFocusListenerRecursively(Container container, FocusListener focusListener) {
    final Component[] components = container.getComponents();
    for (int i = 0; i < components.length; i++) {
        Component component = components[i];
        if (component.isFocusable() && !(component instanceof JLabel)) {
            component.addFocusListener(focusListener);
        }
        if (component instanceof Container) {
            if (!(component instanceof SectionNodePanel)) {
                addFocusListenerRecursively((Container) component, focusListener);
            }
        }
    }
}
 
Example 34
Project: incubator-netbeans   File: FixDuplicateImportStmts.java   View source code 5 votes vote down vote up
private JComboBox createComboBox(CandidateDescription[] choices, CandidateDescription defaultValue, Font font, FocusListener listener ) {
    JComboBox combo = new JComboBox(choices);
    combo.setSelectedItem(defaultValue);
    combo.getAccessibleContext().setAccessibleDescription(getBundleString("FixDupImportStmts_Combo_ACSD")); //NOI18N
    combo.getAccessibleContext().setAccessibleName(getBundleString("FixDupImportStmts_Combo_Name_ACSD")); //NOI18N
    combo.setOpaque(false);
    combo.setFont( font );
    combo.addFocusListener( listener );
    combo.setEnabled( choices.length > 1 );
    combo.setRenderer( new DelegatingRenderer(combo.getRenderer()));
    InputMap inputMap = combo.getInputMap( JComboBox.WHEN_FOCUSED );
    inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_SPACE, 0), "showPopup" ); //NOI18N
    combo.getActionMap().put( "showPopup", new TogglePopupAction() ); //NOI18N
    return combo;
}
 
Example 35
Project: incubator-netbeans   File: ResolveDeclarationsPanel.java   View source code 5 votes vote down vote up
private void initComponentsMore() {
    contentPanel.setLayout(new GridBagLayout());
    contentPanel.setBackground(UIManager.getColor("Table.background")); //NOI18N
    
    int row = 0;
    combos = new ArrayList<>(items.size());

    Font monoSpaced = new Font("Monospaced", Font.PLAIN, new JLabel().getFont().getSize()); //NOI18N
    FocusListener focusListener = new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            Component c = e.getComponent();
            Rectangle r = c.getBounds();
            contentPanel.scrollRectToVisible(r);
        }

    };
    for (int i = 0; i < items.size(); i++) {
        ResolveDeclarationItem item = items.get(i);
        JComboBox jComboBox = createComboBox(item, monoSpaced, focusListener);
        combos.add(jComboBox);

        JLabel lblSimpleName = new JLabel(item.getName());
        lblSimpleName.setOpaque(false);
        lblSimpleName.setFont(monoSpaced);
        lblSimpleName.setLabelFor(jComboBox);

        contentPanel.add(lblSimpleName, new GridBagConstraints(0, row, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 5, 2, 5), 0, 0));
        contentPanel.add(jComboBox, new GridBagConstraints(1, row++, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 5, 2, 5), 0, 0));
    }

    contentPanel.add(new JLabel(), new GridBagConstraints(2, row, 2, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    Dimension d = contentPanel.getPreferredSize();
    d.height = getRowHeight() * Math.min(combos.size(), 6);

}
 
Example 36
Project: incubator-netbeans   File: WeakListenerImpl.java   View source code 5 votes vote down vote up
/** Delegates to the original listener.
*/
@Override public void focusGained(FocusEvent ev) {
    FocusListener l = (FocusListener) super.get(ev);

    if (l != null) {
        l.focusGained(ev);
    }
}
 
Example 37
Project: rapidminer   File: AutoCompletionComboBox.java   View source code 5 votes vote down vote up
@Override
public synchronized void addFocusListener(FocusListener l) {
	// workaround for java bug #6433257
	for (Component c : getComponents()) {
		c.addFocusListener(l);
	}
}
 
Example 38
Project: openjdk-jdk10   File: ComponentOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code Component.addFocusListener(FocusListener)} through queue
 */
public void addFocusListener(final FocusListener focusListener) {
    runMapping(new MapVoidAction("addFocusListener") {
        @Override
        public void map() {
            getSource().addFocusListener(focusListener);
        }
    });
}
 
Example 39
Project: openjdk-jdk10   File: ComponentOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code Component.removeFocusListener(FocusListener)} through queue
 */
public void removeFocusListener(final FocusListener focusListener) {
    runMapping(new MapVoidAction("removeFocusListener") {
        @Override
        public void map() {
            getSource().removeFocusListener(focusListener);
        }
    });
}
 
Example 40
Project: oxygen-git-plugin   File: StagingPanel.java   View source code 5 votes vote down vote up
/**
 * Adds a focus listener on the component and its descendents.
 * 
 * @param c
 *          The component.
 * @param focusListener
 *          Focus Listener.
 */
private void installFocusListener(Component c, FocusListener focusListener) {
	c.addFocusListener(focusListener);

	if (c instanceof Container) {
		Container container = (Container) c;
		int componentCount = container.getComponentCount();
		for (int i = 0; i < componentCount; i++) {
			Component child = container.getComponent(i);
			installFocusListener(child, focusListener);
		}
	}
}