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


Java ClipboardOwner类代码示例

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


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

示例1: superSetContents

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
private synchronized void superSetContents(Transferable t, ClipboardOwner o) {
    if (this.contents != null) {
        transferableOwnershipLost(this.contents);
    }

    final ClipboardOwner oldOwner = this.owner;
    final Transferable oldContents = this.contents;

    this.owner = o;
    this.contents = t;

    if (oldOwner != null && oldOwner != owner) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                oldOwner.lostOwnership(NbClipboard.this, oldContents);
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:NbClipboard.java

示例2: actionPerformed

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
public void actionPerformed(ActionEvent ev) {
    try {
        Transferable trans = t.paste();
        Clipboard clipboard = getClipboard();

        if (trans != null) {
            ClipboardOwner owner = (trans instanceof ClipboardOwner) ? (ClipboardOwner) trans
                                                                     : new StringSelection(""); // NOI18N
            clipboard.setContents(trans, owner);
        }
    } catch (UserCancelException exc) {
        // ignore - user just pressed cancel in some dialog....
    } catch (IOException e) {
        Exceptions.printStackTrace(e);
    } finally {
        EventQueue.invokeLater(this);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:PasteAction.java

示例3: setClipboardString

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
/**
 * Stores the given string in the system clipboard
 */
public static void setClipboardString(String copyText)
{
    if (!StringUtils.isEmpty(copyText))
    {
        try
        {
            StringSelection stringselection = new StringSelection(copyText);
            Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, (ClipboardOwner)null);
        }
        catch (Exception var2)
        {
            ;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:19,代码来源:GuiScreen.java

示例4: lostOwnershipNow

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
protected void lostOwnershipNow(final AppContext disposedContext) {
    final SunClipboard sunClipboard = SunClipboard.this;
    ClipboardOwner owner = null;
    Transferable contents = null;

    synchronized (sunClipboard) {
        final AppContext context = sunClipboard.contentsContext;

        if (context == null) {
            return;
        }

        if (disposedContext == null || context == disposedContext) {
            owner = sunClipboard.owner;
            contents = sunClipboard.contents;
            sunClipboard.contentsContext = null;
            sunClipboard.owner = null;
            sunClipboard.contents = null;
            sunClipboard.clearNativeContext();
            context.removePropertyChangeListener
                    (AppContext.DISPOSED_PROPERTY_NAME, sunClipboard);
        } else {
            return;
        }
    }
    if (owner != null) {
        owner.lostOwnership(sunClipboard, contents);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:SunClipboard.java

示例5: setContents

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
public synchronized void setContents(Transferable contents,
                                     ClipboardOwner owner) {
    // 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
    // should throw NPE
    if (contents == null) {
        throw new NullPointerException("contents");
    }

    initContext();

    final ClipboardOwner oldOwner = this.owner;
    final Transferable oldContents = this.contents;

    try {
        this.owner = owner;
        this.contents = new TransferableProxy(contents, true);

        setContentsNative(contents);
    } finally {
        if (oldOwner != null && oldOwner != owner) {
            EventQueue.invokeLater(() -> oldOwner.lostOwnership(SunClipboard.this, oldContents));
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:SunClipboard.java

示例6: execute

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
public void execute() {
    System.out.println("Hello world");
    final ClipboardOwner clipboardOwner = new ClipboardOwner() {
        public void lostOwnership(Clipboard clipboard, Transferable contents) {
            System.exit(0);
        }
    };
    clipboard.setContents(transferable, clipboardOwner);
    synchronized (o) {
        try {
            o.wait();
        } catch (InterruptedException ie) {
            ie.printStackTrace();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:GetContentsInterruptedTest.java

示例7: performAction

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
@Override
public void performAction() {
    final WordCountTopComponent win = WordCountTopComponent.findInstance();
    if (win == null) {
        return ;
    }
    
    // the wordcount table model
    final WordCountTableModel wctm = win.getWordCountTableModel();
    if (wctm == null) {
        return ;
    }
    // format the wordcount table model
    final StringBuffer sb = new StringBuffer();
    
    buildHeader1( wctm, sb );
    buildContentInfo( win, sb );
    buildContentWc( wctm, sb );
    
    // copy sb to the clipboard
    final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    final StringSelection stringSelection = new StringSelection(sb.toString());
    final ClipboardOwner owner = stringSelection;
    clipboard.setContents(stringSelection, owner );
}
 
开发者ID:bernhardhuber,项目名称:netbeansplugins,代码行数:26,代码来源:ExportDataAction.java

示例8: func_146821_q

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
private void func_146821_q()
{
    Session var1 = this.mc.getSession();
    McoClient var2 = new McoClient(var1.getSessionID(), var1.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy());

    try
    {
        String var3 = var2.func_148708_h(this.field_146846_h);
        Clipboard var4 = Toolkit.getDefaultToolkit().getSystemClipboard();
        var4.setContents(new StringSelection(var3), (ClipboardOwner)null);
        this.func_146823_a(var3);
    }
    catch (ExceptionMcoService var5)
    {
        logger.error("Couldn\'t download world data");
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:18,代码来源:GuiScreenBackup.java

示例9: actionPerformed

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
protected void actionPerformed(GuiButton p_146284_1_)
{
    if (p_146284_1_.enabled)
    {
        if (p_146284_1_.id == 0)
        {
            this.mc.displayGuiScreen(this.field_146780_f);
        }
        else if (p_146284_1_.id == 1)
        {
            String var2 = "https://account.mojang.com/buy/realms?wid=" + this.field_146781_g.field_148812_a + "?pid=" + this.func_146777_g();
            Clipboard var3 = Toolkit.getDefaultToolkit().getSystemClipboard();
            var3.setContents(new StringSelection(var2), (ClipboardOwner)null);
            this.func_146779_a(var2);
        }
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:18,代码来源:GuiScreenSubscription.java

示例10: pasteString

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
/***
 * Waits until the system clipboard is not being used by another WebDriver instance,
 * then populates the system clipboard with the value previously stored for the current WebDriver instance
 * and finally sends the CTRL + v command to the specified locator
 * <p>
 * {@link #copyString(String) copyString} method should have been called before
 *
 * @param locator WebLocator where the value from clipboard corresponding to the current WebDriver instance should be pasted
 */
public static void pasteString(WebLocator locator) {
    waitForUnlockedClipboard();
    lockClipboard();
    String value = clipboardContents.get(((RemoteWebDriver) WebDriverConfig.getDriver()).getSessionId().toString());
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(value),
            new ClipboardOwner() {
                @Override
                public void lostOwnership(final java.awt.datatransfer.Clipboard clipboard, final Transferable contents) {
                    // do nothing
                }
            });
    try {
        locator.sendKeys(Keys.CONTROL, "v");
    } catch (Throwable throwable) {
        // Making sure clipboard would not unexpectedly remain locked
        unlockClipboard();
    }
    unlockClipboard();
}
 
开发者ID:sdl,项目名称:Testy,代码行数:29,代码来源:MultiThreadClipboardUtils.java

示例11: CopySeedMenuItem

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
private CopySeedMenuItem() {
	super("Copy Seed to Clipboard");
	
	setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK));
	
	addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			StringSelection stringSelection = new StringSelection(Options.instance.seed + "");
			Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
			clipboard.setContents(stringSelection, new ClipboardOwner() {
				@Override
				public void lostOwnership(Clipboard arg0, Transferable arg1) {
					// TODO Auto-generated method stub
					
				}
			});
		}
	});
}
 
开发者ID:skiphs,项目名称:AMIDST,代码行数:21,代码来源:AmidstMenu.java

示例12: setContents

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
@Override
public synchronized void setContents(Transferable contents, ClipboardOwner owner) {
    setContentsCounter++;
    if( pretendToBeBusy ) {
        pretendToBeBusy = false;
        throw new IllegalStateException();
    }
    super.setContents(contents, owner);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:NbClipboardTest.java

示例13: setContents

import java.awt.datatransfer.ClipboardOwner; //导入依赖的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

示例14: setContents

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
public synchronized void setContents(Transferable contents,
                                     ClipboardOwner owner) {
    // 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
    // should throw NPE
    if (contents == null) {
        throw new NullPointerException("contents");
    }

    initContext();

    final ClipboardOwner oldOwner = this.owner;
    final Transferable oldContents = this.contents;

    try {
        this.owner = owner;
        this.contents = new TransferableProxy(contents, true);

        setContentsNative(contents);
    } finally {
        if (oldOwner != null && oldOwner != owner) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    oldOwner.lostOwnership(SunClipboard.this, oldContents);
                }
            });
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:SunClipboard.java

示例15: setClipboardString

import java.awt.datatransfer.ClipboardOwner; //导入依赖的package包/类
public static void setClipboardString(String p_146275_0_)
{
	try
	{
		StringSelection stringselection = new StringSelection(p_146275_0_);
		Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, (ClipboardOwner)null);
	}
	catch (Exception exception) {}
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:10,代码来源:GuiScreen.java


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