• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClipboardService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: replaceCopyAction

import javax.jnlp.ClipboardService; //导入依赖的package包/类
/**
 * Replaces the editor's default copy action in security restricted
 * environments with one messaging the ClipboardService. Does nothing 
 * if not restricted.
 * 
 * @param editor the editor to replace 
 */
public static void replaceCopyAction(final JEditorPane editor) {
    if (!isRestricted()) return;
    Action safeCopy = new AbstractAction() {
        
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                ClipboardService cs = (ClipboardService)ServiceManager.lookup
                    ("javax.jnlp.ClipboardService");
                StringSelection transferable = new StringSelection(editor.getSelectedText());
                cs.setContents(transferable);
            } catch (Exception e1) {
                // do nothing
            }
        }
    };
    editor.getActionMap().put(DefaultEditorKit.copyAction, safeCopy);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:DemoUtils.java


示例2: getContents

import javax.jnlp.ClipboardService; //导入依赖的package包/类
/**
 * Gets the contents of the system clipboard
 *
 * @return The text system clipboad contents
 */
public String getContents() {
    String contents = null;
    try {
        ClipboardService cs = (ClipboardService) ServiceManager.lookup(ClipboardService.class.getName());
        Transferable data = cs.getContents();
        if (data != null && data.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            contents = ((String) (data.getTransferData(DataFlavor.stringFlavor)));
        }
    } catch (Exception e) {
        logger.log(Level.WARNING, "Failed getting the clipboard contents: " + e.getMessage(), e);
    }
    return contents;
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:19,代码来源:ClipboardHandlerJNLP.java


示例3: setContents

import javax.jnlp.ClipboardService; //导入依赖的package包/类
/**
 * Sets the contents of the system clipboard
 *
 * @param s clipboard contents to set
 */
public void setContents(String s) {
    try {
        ClipboardService cs = (ClipboardService) ServiceManager.lookup(ClipboardService.class.getName());
        cs.setContents(new StringSelection(s));
    } catch (Exception e) {
        logger.log(Level.WARNING, "Failed setting the clipboard contents: " + e.getMessage(), e);
    }
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:14,代码来源:ClipboardHandlerJNLP.java


示例4: ClipboardServiceTextArea

import javax.jnlp.ClipboardService; //导入依赖的package包/类
protected ClipboardServiceTextArea() {
    super();
    try {
        cs = (ClipboardService) ServiceManager.lookup("javax.jnlp.ClipboardService");
    } catch (UnavailableServiceException ex) {
        cs = null;
    }
}
 
开发者ID:aterai,项目名称:java-swing-tips,代码行数:9,代码来源:MainPanel.java


示例5: MainPanel

import javax.jnlp.ClipboardService; //导入依赖的package包/类
public MainPanel() {
    super(new GridLayout(2, 1));
    try {
        cs = (ClipboardService) ServiceManager.lookup("javax.jnlp.ClipboardService");
    } catch (UnavailableServiceException ex) {
        cs = null;
    }
    JTextArea textArea = new JTextArea() {
        @Override public void copy() {
            if (Objects.nonNull(cs)) {
                cs.setContents(new StringSelection(getSelectedText()));
            } else {
                super.copy();
            }
        }
        @Override public void cut() {
            if (Objects.nonNull(cs)) {
                cs.setContents(new StringSelection(getSelectedText()));
            } else {
                super.cut();
            }
        }
        @Override public void paste() {
            if (Objects.nonNull(cs)) {
                Transferable tr = cs.getContents();
                if (tr.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                    getTransferHandler().importData(this, tr);
                }
            } else {
                super.paste();
            }
        }
    };
    textArea.setComponentPopupMenu(new TextComponentPopupMenu(textArea));

    add(makeTitledPanel("ClipboardService", new JScrollPane(textArea)));
    add(makeTitledPanel("Default", new JScrollPane(new JTextArea())));
    setPreferredSize(new Dimension(320, 240));
}
 
开发者ID:aterai,项目名称:java-swing-tips,代码行数:40,代码来源:MainPanel.java


示例6: getActionCut

import javax.jnlp.ClipboardService; //导入依赖的package包/类
Action getActionCut(){
	if(actionCut == null){
		actionCut= new AbstractAction(){
			private static final long serialVersionUID = -8541286290535301269L;
			{
				putValue(NAME,I18n.getString(I18n.cut));
	            putValue(SHORT_DESCRIPTION, I18n.getString(I18n.cutText));
	            putValue(ACCELERATOR_KEY,KeyStroke.getKeyStroke("control X"));
	            putValue(MNEMONIC_KEY,KeyStroke.getKeyStroke("t"));
	        }
			public void actionPerformed(ActionEvent e) {
				File f=activeFile();
				if(f != null){
					String s=f.getEditor().getSelectedText();
					if(getRestrictedEdit() || !getJnlpServicesAvailable()){
						setLocalClipboard(s);
					}
					else{
						try{
							javax.jnlp.ClipboardService cs=getClipboardService();
							if(cs!=null){
								cs.setContents(new StringSelection(s));
							}
						}catch (Throwable e1) {
							setLocalClipboard(s);
						}
					}
					f.getEditor().replaceSelection("");
				}
			}};
		}
	return actionCut;
}
 
开发者ID:jcrodriguez-dis,项目名称:ACodeEditor,代码行数:34,代码来源:Main.java


示例7: getActionCopy

import javax.jnlp.ClipboardService; //导入依赖的package包/类
Action getActionCopy(){
	if(actionCopy == null){
		actionCopy= new AbstractAction(){
			private static final long serialVersionUID = 1885767447085086761L;
			{
				putValue(NAME,I18n.getString(I18n.copy));
	            putValue(SHORT_DESCRIPTION, I18n.getString(I18n.copyText));
	            putValue(ACCELERATOR_KEY,KeyStroke.getKeyStroke("control C"));
	            putValue(MNEMONIC_KEY,KeyStroke.getKeyStroke("c"));
	        }
			public void actionPerformed(ActionEvent e) {
				File f=activeFile();
				if(f != null){
					String s=f.getEditor().getSelectedText();
					if(getRestrictedEdit() || !getJnlpServicesAvailable()){
						setLocalClipboard(s);
					}
					else{
						try{
							javax.jnlp.ClipboardService cs=getClipboardService();
							if(cs!=null){
								cs.setContents(new StringSelection(s));
							}
						}catch (Throwable e1) {
							setLocalClipboard(s);
						}
					}
				}
			}};
	}
	return actionCopy;
}
 
开发者ID:jcrodriguez-dis,项目名称:ACodeEditor,代码行数:33,代码来源:Main.java


示例8: getActionPaste

import javax.jnlp.ClipboardService; //导入依赖的package包/类
Action getActionPaste(){
	if(actionPaste == null){
		actionPaste= new AbstractAction(){
			private static final long serialVersionUID = -1183210964688352085L;
			{ 
				putValue(NAME, I18n.getString(I18n.paste));
	            putValue(SHORT_DESCRIPTION, I18n.getString(I18n.pasteText));
	            putValue(ACCELERATOR_KEY,KeyStroke.getKeyStroke("control V"));
	            putValue(MNEMONIC_KEY,new Integer(KeyEvent.VK_V));
	        }
			public void actionPerformed(ActionEvent e) {
				File f=activeFile();
				if(f != null){
					String s="";
					if(getRestrictedEdit() || !getJnlpServicesAvailable()){
						s=getLocalClipboard();
					}
					else{
						try{
							javax.jnlp.ClipboardService cs=getClipboardService();
							if(cs!=null){
								Transferable t=cs.getContents();
								s = t.getTransferData(DataFlavor.stringFlavor).toString();
							}
						}catch (Throwable e1) {
							s=getLocalClipboard();
						}
					}
					f.getEditor().replaceSelection(s);
				}
			}};
	}
	return actionPaste;
}
 
开发者ID:jcrodriguez-dis,项目名称:ACodeEditor,代码行数:35,代码来源:Main.java


示例9: getContents

import javax.jnlp.ClipboardService; //导入依赖的package包/类
/**
 * Gets the contents of the system clipboard
 * 
 * @return The text system clipboad contents 
 */
public String getContents() {
	String contents = null;
	try {
		ClipboardService cs = (ClipboardService)ServiceManager.lookup(ClipboardService.class.getName());
		Transferable data = cs.getContents();
		if (data != null && data.isDataFlavorSupported(DataFlavor.stringFlavor)) {
			contents = ((String)(data.getTransferData(DataFlavor.stringFlavor)));
		}
	} catch (Exception e) {
		logger.log(Level.WARNING, "Failed getting the clipboard contents: " + e.getMessage(), e );
	}
	return contents;
}
 
开发者ID:ahmedmoustafa,项目名称:JAligner,代码行数:19,代码来源:ClipboardHandlerJNLP.java


示例10: setContents

import javax.jnlp.ClipboardService; //导入依赖的package包/类
/**
 * Sets the contents of the system clipboard
 * 
 * @param s clipboard contents to set
 */
public void setContents(String s) {
	try {
		ClipboardService cs = (ClipboardService)ServiceManager.lookup(ClipboardService.class.getName());
		cs.setContents(new StringSelection(s));
	} catch (Exception e) {
		logger.log(Level.WARNING, "Failed setting the clipboard contents: " + e.getMessage(), e );
	}
}
 
开发者ID:ahmedmoustafa,项目名称:JAligner,代码行数:14,代码来源:ClipboardHandlerJNLP.java


示例11: initialize

import javax.jnlp.ClipboardService; //导入依赖的package包/类
static private synchronized void initialize() {
    if (_initialized) return;
    _initialized = true;
    try {
        _cs = (ClipboardService)ServiceManager.lookup("javax.jnlp.ClipboardService");
    } catch(UnavailableServiceException e) {
        _cs = null;
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:10,代码来源:ClipboardHandler.java


示例12: getClipboardService

import javax.jnlp.ClipboardService; //导入依赖的package包/类
/**
 * @return the ClipboardService reference, or null if the service is
 * unavailable.
 */
public static ClipboardService getClipboardService() {
    return (ClipboardService) getService("javax.jnlp.ClipboardService");
}
 
开发者ID:GITNE,项目名称:icedtea-web,代码行数:8,代码来源:ServiceUtil.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ZNRecord类代码示例发布时间:2022-05-23
下一篇:
Java MarkerManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap