最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SWT(JFace)體驗(yàn)之復(fù)制粘貼

 更新時(shí)間:2009年06月25日 12:16:18   作者:  
SWT(JFace)體驗(yàn)之復(fù)制粘貼
演示代碼如下:
復(fù)制代碼 代碼如下:

package swt_jface.demo11;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.RTFTransfer;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.dnd.TransferData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
public class CopyPaste {

    Display display = new Display();
    Shell shell = new Shell(display);
    public CopyPaste() {
        shell.setLayout(new GridLayout());

        ToolBar toolBar = new ToolBar(shell, SWT.FLAT);
        ToolItem itemCopy = new ToolItem(toolBar, SWT.PUSH);
        ToolItem itemPaste = new ToolItem(toolBar, SWT.PUSH);
        itemCopy.setText("Copy");
        itemPaste.setText("Paste");

        itemCopy.addListener(SWT.Selection, new Listener() {
            public void handleEvent(Event event) {
                Clipboard clipboard = new Clipboard(display);
                String plainText = "Hello World";
                String rtfText = "{\\rtf1\\b Hello World}";
                TextTransfer textTransfer = TextTransfer.getInstance();
                RTFTransfer rftTransfer = RTFTransfer.getInstance();
                clipboard.setContents(new String[]{plainText, rtfText}, new Transfer[]{textTransfer, rftTransfer});
                clipboard.dispose();
            }
        });

        itemPaste.addListener(SWT.Selection, new Listener() {
            public void handleEvent(Event event) {
                Clipboard clipboard = new Clipboard(display);
                TransferData[] transferDatas = clipboard.getAvailableTypes();
                for(int i=0; i<transferDatas.length; i++) {
                    if(RTFTransfer.getInstance().isSupportedType(transferDatas[i])) {
                        System.out.println("Data is available in RTF format");
                        break;
                    }
                }
                String plainText = (String)clipboard.getContents(TextTransfer.getInstance());
                String rtfText = (String)clipboard.getContents(RTFTransfer.getInstance());
                System.out.println("PLAIN: " + plainText + "\n" + "RTF: " + rtfText);
                clipboard.dispose();
            }
        });
        shell.pack();
        shell.open();

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
    }
    public static void main(String[] args) {
        new CopyPaste();
    }
}

相關(guān)文章

  • spring基礎(chǔ)概念A(yù)OP與動(dòng)態(tài)代理理解

    spring基礎(chǔ)概念A(yù)OP與動(dòng)態(tài)代理理解

    這篇文章主要為大家詳細(xì)介紹了spring基礎(chǔ)概念A(yù)OP與動(dòng)態(tài)代理,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • Mybatis-plus 雙主鍵的實(shí)現(xiàn)示例

    Mybatis-plus 雙主鍵的實(shí)現(xiàn)示例

    本文主要介紹了Mybatis-plus 雙主鍵的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2024-05-05
  • Hibernate緩存機(jī)制實(shí)例代碼解析

    Hibernate緩存機(jī)制實(shí)例代碼解析

    這篇文章主要介紹了Hibernate緩存機(jī)制實(shí)例代碼解析,介紹了查詢緩存,一級(jí)二級(jí)緩存等內(nèi)容,分享了相關(guān)代碼示例,小編覺(jué)得還是挺不錯(cuò)的,具有一定借鑒價(jià)值,需要的朋友可以參考下
    2018-02-02
  • Springboot處理跨域的實(shí)現(xiàn)方式(附Demo)

    Springboot處理跨域的實(shí)現(xiàn)方式(附Demo)

    這篇文章主要介紹了Springboot處理跨域的實(shí)現(xiàn)方式(附Demo),具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2025-04-04
  • Java獲取項(xiàng)目路徑方式System.getProperty(“user.dir“)

    Java獲取項(xiàng)目路徑方式System.getProperty(“user.dir“)

    這篇文章主要介紹了Java獲取項(xiàng)目路徑方式System.getProperty(“user.dir“),具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • 一文詳解如何在SpringMVC的視圖中渲染模型數(shù)據(jù)

    一文詳解如何在SpringMVC的視圖中渲染模型數(shù)據(jù)

    SpringMVC是一個(gè)基于Spring框架的Web框架,它提供了一種方便的方式來(lái)處理 HTTP 請(qǐng)求和響應(yīng),在SpringMVC中,視圖是用來(lái)渲染模型數(shù)據(jù)的組件,它們負(fù)責(zé)將模型數(shù)據(jù)轉(zhuǎn)換為HTML、JSON、XML等格式的響應(yīng),在本文中,我們將討論如何在SpringMVC中的視圖中渲染模型數(shù)據(jù)
    2023-07-07
  • 如何使用Spring-Test對(duì)Spring框架進(jìn)行單元測(cè)試

    如何使用Spring-Test對(duì)Spring框架進(jìn)行單元測(cè)試

    這篇文章主要介紹了如何使用Spring-Test對(duì)Spring框架進(jìn)行單元測(cè)試,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-09-09
  • 使用springboot 打包插件去除jar包瘦身

    使用springboot 打包插件去除jar包瘦身

    這篇文章主要介紹了使用springboot 打包插件去除jar包瘦身的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-07-07
  • 安裝多個(gè)版本JDK后使用時(shí)的切換方法總結(jié)

    安裝多個(gè)版本JDK后使用時(shí)的切換方法總結(jié)

    我們平時(shí)在window上做開(kāi)發(fā)的時(shí)候,可能需要同時(shí)開(kāi)發(fā)兩個(gè)甚至多個(gè)項(xiàng)目,有時(shí)不同的項(xiàng)目對(duì)JDK的版本要求有區(qū)別,下面這篇文章主要給大家介紹了安裝多個(gè)版本JDK后使用的切換方法,需要的朋友可以參考借鑒,下面來(lái)一起看看吧。
    2017-01-01
  • jar包中替換指定的class文件方法詳解

    jar包中替換指定的class文件方法詳解

    這篇文章主要為大家介紹了jar包中替換指定的class文件方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-11-11

最新評(píng)論

博爱县| 珲春市| 宁陕县| 绥滨县| 东兰县| 马尔康县| 麻栗坡县| 绥滨县| 固原市| 丁青县| 南城县| 莲花县| 鹤岗市| 墨脱县| 贺兰县| 万源市| 周口市| 仁布县| 福安市| 永定县| 绥宁县| 安顺市| 鄂州市| 万州区| 南和县| 海兴县| 新干县| 江安县| 武隆县| 高州市| 浏阳市| 当涂县| 南川市| 富锦市| 岱山县| 平阴县| 九江市| 托克逊县| 噶尔县| 定陶县| 鸡西市|