当前位置: 首页>>代码示例>>Java>>正文


Java FocusListener类代码示例

本文整理汇总了Java中java.awt.event.FocusListener的典型用法代码示例。如果您正苦于以下问题:Java FocusListener类的具体用法?Java FocusListener怎么用?Java FocusListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FocusListener类属于java.awt.event包,在下文中一共展示了FocusListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getA11YJTextFieldSupport

import java.awt.event.FocusListener; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:A11YUtil.java

示例2: focusLost

import java.awt.event.FocusListener; //导入依赖的package包/类
/** Delegates to the original listener.
*/
@Override public void focusLost(FocusEvent ev) {
    FocusListener l = (FocusListener) super.get(ev);

    if (l != null) {
        l.focusLost(ev);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:WeakListenerImpl.java

示例3: createAndShowGUI

import java.awt.event.FocusListener; //导入依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:bug4624207.java

示例4: use

import java.awt.event.FocusListener; //导入依赖的package包/类
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 );
            }
        }
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:23,代码来源:BoundAssociation.java

示例5: use

import java.awt.event.FocusListener; //导入依赖的package包/类
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 );
            }
        }
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:22,代码来源:BoundProperty.java

示例6: testUndecorateTextComponent

import java.awt.event.FocusListener; //导入依赖的package包/类
/**
 * 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))));
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:19,代码来源:AutoCompleteDecoratorTest.java

示例7: init

import java.awt.event.FocusListener; //导入依赖的package包/类
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));
}
 
开发者ID:dvorka,项目名称:mindraider,代码行数:17,代码来源:RichTextAnnotationRenderer.java

示例8: removeAllListeners

import java.awt.event.FocusListener; //导入依赖的package包/类
/**
 * 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);
	}
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:26,代码来源:MungePen.java

示例9: setFocusListener

import java.awt.event.FocusListener; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:cf86,项目名称:MP3ToolKit,代码行数:27,代码来源:ID3RightPanel.java

示例10: getListeners

import java.awt.event.FocusListener; //导入依赖的package包/类
@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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:Component.java

示例11: TextComponent

import java.awt.event.FocusListener; //导入依赖的package包/类
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());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:TextComponent.java

示例12: testAddRemoveFocusListener

import java.awt.event.FocusListener; //导入依赖的package包/类
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);

}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:AccessibleAWTComponentTest.java

示例13: requestFocusInWindowForComponent

import java.awt.event.FocusListener; //导入依赖的package包/类
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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:JComponent_MultithreadedTest.java

示例14: requestFocusForComponent

import java.awt.event.FocusListener; //导入依赖的package包/类
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();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:JComponent_MultithreadedTest.java

示例15: ActionsBuilder

import java.awt.event.FocusListener; //导入依赖的package包/类
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)
    );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:CollapsibleSectionPanel.java


注:本文中的java.awt.event.FocusListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。