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


Java FlavorListener类代码示例

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


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

示例1: makeSureSystemClipboardContainsString

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
private static void makeSureSystemClipboardContainsString(
    Clipboard sys, NbClipboard clip
) throws InterruptedException {
    final CountDownLatch wait = new CountDownLatch(1);
    class FL implements FlavorListener {
        @Override
        public void flavorsChanged(FlavorEvent e) {
            wait.countDown();
        }
    }
    FL fl = new FL();
    sys.addFlavorListener(fl);
    StringSelection ss = new StringSelection("empty");
    clip.setContents(ss, ss);
    wait.await();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:NbClipboardTimeoutTest.java

示例2: removeFlavorListener

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
public synchronized void removeFlavorListener(FlavorListener listener) {
    if (listener == null) {
        return;
    }
    AppContext appContext = AppContext.getAppContext();
    EventListenerAggregate contextFlavorListeners = (EventListenerAggregate)
            appContext.get(CLIPBOARD_FLAVOR_LISTENER_KEY);
    if (contextFlavorListeners == null){
        //else we throw NullPointerException, but it is forbidden
        return;
    }
    if (contextFlavorListeners.remove(listener) &&
            --numberOfFlavorListeners == 0) {
        unregisterClipboardViewerChecked();
        currentDataFlavors = null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:SunClipboard.java

示例3: removeFlavorListener

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
public synchronized void removeFlavorListener(FlavorListener listener) {
    if (listener == null) {
        return;
    }
    AppContext appContext = AppContext.getAppContext();
    EventListenerAggregate contextFlavorListeners = (EventListenerAggregate)
            appContext.get(CLIPBOARD_FLAVOR_LISTENER_KEY);
    if (contextFlavorListeners == null){
        //else we throw NullPointerException, but it is forbidden
        return;
    }
    if (contextFlavorListeners.remove(listener) &&
            --numberOfFlavorListeners == 0) {
        unregisterClipboardViewerChecked();
        currentFormats = null;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:SunClipboard.java

示例4: addFlavorListener

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
public synchronized void addFlavorListener(FlavorListener listener) {
    if (listener == null) {
        return;
    }
    AppContext appContext = AppContext.getAppContext();
    Set<FlavorListener> flavorListeners = getFlavorListeners(appContext);
    if (flavorListeners == null) {
        flavorListeners = new HashSet<>();
        appContext.put(CLIPBOARD_FLAVOR_LISTENER_KEY, flavorListeners);
    }
    flavorListeners.add(listener);

    if (numberOfFlavorListeners++ == 0) {
        long[] currentFormats = null;
        try {
            openClipboard(null);
            currentFormats = getClipboardFormats();
        } catch (final IllegalStateException ignored) {
        } finally {
            closeClipboard();
        }
        this.currentFormats = currentFormats;

        registerClipboardViewerChecked();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:SunClipboard.java

示例5: checkChange

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
/**
 * Checks change of the {@code DataFlavor}s and, if necessary,
 * posts notifications on {@code FlavorEvent}s to the
 * AppContexts' EDTs.
 * The parameter {@code formats} is null iff we have just
 * failed to get formats available on the clipboard.
 *
 * @param formats data formats that have just been retrieved from
 *        this clipboard
 */
protected final void checkChange(final long[] formats) {
    if (Arrays.equals(formats, currentFormats)) {
        // we've been able to successfully get available on the clipboard
        // DataFlavors this and previous time and they are coincident;
        // don't notify
        return;
    }
    currentFormats = formats;

    for (final AppContext appContext : AppContext.getAppContexts()) {
        if (appContext == null || appContext.isDisposed()) {
            continue;
        }
        Set<FlavorListener> flavorListeners = getFlavorListeners(appContext);
        if (flavorListeners != null) {
            for (FlavorListener listener : flavorListeners) {
                if (listener != null) {
                    PeerEvent peerEvent = new PeerEvent(this,
                            () -> listener.flavorsChanged(new FlavorEvent(SunClipboard.this)),
                            PeerEvent.PRIORITY_EVENT);
                    SunToolkit.postEvent(appContext, peerEvent);
                }
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:SunClipboard.java

示例6: GUIClipboard

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
/** Creates a new instance of GUIClipboard */
public GUIClipboard(GUIPrism pr)
{
    super(pr, false);
    this.prism = pr;
    initComponents();
    doUndoManagerEnables();
    doClipboardEnables();
    
    /* Listen to clipboard events. */
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    clipboard.addFlavorListener(new FlavorListener() {
    	public void flavorsChanged(FlavorEvent e) {
    		doClipboardEnables();
    	}
    });
}
 
开发者ID:musaeed,项目名称:Prism-gsoc16,代码行数:18,代码来源:GUIClipboard.java

示例7: addFlavorListener

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
@Override
public synchronized void addFlavorListener(FlavorListener listener) {
    Boolean prev = FIRING.get();
    try {
        FIRING.set(true);
        super.addFlavorListener(listener); 
    } finally {
        FIRING.set(prev);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:NbClipboard.java

示例8: fireChange

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
final void fireChange() {
    Boolean prev = FIRING.get();
    try {
        FIRING.set(true);
        FlavorEvent e = new FlavorEvent(this);
        fireClipboardChange();
        for (FlavorListener l : super.getFlavorListeners()) {
            l.flavorsChanged(e);
        }
    } finally {
        FIRING.set(prev);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:NbClipboard.java

示例9: registerListener

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
private void registerListener() {
    if (flavL == null) {
        Clipboard c = getClipboard();
        if (c != null) {
            flavL = WeakListeners.create(FlavorListener.class, this, c);
            c.addFlavorListener(flavL);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ExplorerActionsImpl.java

示例10: setContents

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
@Override
public void setContents (Transferable t, ClipboardOwner o) {
    super.setContents (t, o);
    fireClipboardChange ();
    FlavorEvent ev = new FlavorEvent(this);
    for (FlavorListener flavorListener : getFlavorListeners()) {
        flavorListener.flavorsChanged(ev);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ExplorerPanelTest.java

示例11: removeFlavorListener

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
public synchronized void removeFlavorListener(FlavorListener listener) {
    if (listener == null) {
        return;
    }
    Set<FlavorListener> flavorListeners = getFlavorListeners(AppContext.getAppContext());
    if (flavorListeners == null){
        //else we throw NullPointerException, but it is forbidden
        return;
    }
    if (flavorListeners.remove(listener) && --numberOfFlavorListeners == 0) {
        unregisterClipboardViewerChecked();
        currentFormats = null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:SunClipboard.java

示例12: PasteAction

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
public PasteAction(Lookup context) {
    super(context, ClipboardUtil.Pasteable.class);
    setDisplayName(Bundle.CTL_PasteAction());
    setSmallIconPath(IMG_16);
    setLargeIconPath(IMG_32);
    
    cb = Toolkit.getDefaultToolkit().getSystemClipboard();
    if(cb == null) {
        logger.warning("SystemClipboard not found! CopyAction will be disabled!");
    } else {
        cb.addFlavorListener(WeakListeners.create(FlavorListener.class, cbListener, cb));
    }
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:14,代码来源:PasteAction.java

示例13: getFlavorListeners

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
@Override
public  FlavorListener[] getFlavorListeners() {
    return new FlavorListener[0];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:NbClipboard.java

示例14: getFlavorListeners

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
public synchronized FlavorListener[] getFlavorListeners() {
    EventListenerAggregate contextFlavorListeners = (EventListenerAggregate)
            AppContext.getAppContext().get(CLIPBOARD_FLAVOR_LISTENER_KEY);
    return contextFlavorListeners == null ? new FlavorListener[0] :
            (FlavorListener[])contextFlavorListeners.getListenersCopy();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:SunClipboard.java

示例15: getFlavorListeners

import java.awt.datatransfer.FlavorListener; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Set<FlavorListener> getFlavorListeners(AppContext appContext) {
    return (Set<FlavorListener>)appContext.get(CLIPBOARD_FLAVOR_LISTENER_KEY);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:SunClipboard.java


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