求一种软件 又没有一种可以多重复制的软件 如我按ctrl+1 复制到内存中 再按ctrl+2 就可以再开辟一块内存存放 然后再按alt+1和alt+2就能粘贴出来 之前听说有个copypastetool也不好用 如果没有能不能用java写出来一个呢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你获得快捷键再定义变量不就得了?然后再把定义好的list迭代出来 import java.awt.*;import java.awt.event.*; import java.awt.datatransfer.*; public class Test extends Frame implements ActionListener { MenuBar menubar; Menu menu; MenuItem copy,cut,paste; TextArea text1,text2; Clipboard clipboard=null; Test() { clipboard=getToolkit().getSystemClipboard();//获取系统剪贴板。 menubar=new MenuBar(); menu=new Menu( "Edit "); copy=new MenuItem( "copy "); cut=new MenuItem ( "cut "); paste=new MenuItem ( "paste "); text1=new TextArea(20,20); text2=new TextArea(20,20); copy.addActionListener(this); cut.addActionListener(this); paste.addActionListener(this); setLayout(new FlowLayout()); menubar.add(menu); menu.add(copy); menu.add(cut); menu.add(paste); setMenuBar(menubar); add(text1);add(text2); setBounds(100,100,200,250); setVisible(true);pack(); addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {System.exit(0); } }) ; } public void actionPerformed(ActionEvent e) { if(e.getSource()==copy) //拷贝到剪贴板。 { String temp=text1.getSelectedText(); //拖动鼠标选取文本。 StringSelection text=new StringSelection(temp); clipboard.setContents(text,null); } else if(e.getSource()==cut) //剪贴到剪贴板。 { String temp=text1.getSelectedText(); //拖动鼠标选取文本。 StringSelection text=new StringSelection(temp); clipboard.setContents(text,null); int start=text1.getSelectionStart(); int end =text1.getSelectionEnd(); text1.replaceRange( " ",start,end) ; //从Text1中删除被选取的文本。 } else if(e.getSource()==paste) //从剪贴板粘贴数据。 { Transferable contents=clipboard.getContents(this); DataFlavor flavor= DataFlavor.stringFlavor; if( contents.isDataFlavorSupported(flavor)) try{ String str; str=(String)contents.getTransferData(flavor); text2.append(str); } catch(Exception ee){} } } public static void main(String args[]) { Test win=new Test(); } } 困扰很多天的DWR异常,待解决··· JAVA运行时错误,请高手指教 jsf <h:inputHidden >传值的问题 java 中怎样和sqlserver数据库连接 用poi操作excel时,如何拷贝sheet已有的行到新建的sheet中?? 开源项目在Eclipse中目录的疑惑 急!!请高手给小弟指点迷经!在线等! hibernate的hibernate.cfg.xml文件如下: 一道线程的题目 为什么在Jb7中无法创建EJB程序,是否需要配置!高分 struts2在jsp页面提交中文的时候到action中的中文乱码问题 java ant问题
import java.awt.datatransfer.*;
public class Test extends Frame implements ActionListener
{ MenuBar menubar; Menu menu;
MenuItem copy,cut,paste;
TextArea text1,text2;
Clipboard clipboard=null;
Test()
{ clipboard=getToolkit().getSystemClipboard();//获取系统剪贴板。
menubar=new MenuBar();
menu=new Menu( "Edit "); copy=new MenuItem( "copy ");
cut=new MenuItem ( "cut "); paste=new MenuItem ( "paste ");
text1=new TextArea(20,20); text2=new TextArea(20,20);
copy.addActionListener(this); cut.addActionListener(this);
paste.addActionListener(this);
setLayout(new FlowLayout());
menubar.add(menu);
menu.add(copy); menu.add(cut); menu.add(paste);
setMenuBar(menubar);
add(text1);add(text2);
setBounds(100,100,200,250); setVisible(true);pack();
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{System.exit(0);
}
}) ;
}
public void actionPerformed(ActionEvent e)
{ if(e.getSource()==copy) //拷贝到剪贴板。
{ String temp=text1.getSelectedText(); //拖动鼠标选取文本。
StringSelection text=new StringSelection(temp);
clipboard.setContents(text,null);
}
else if(e.getSource()==cut) //剪贴到剪贴板。
{ String temp=text1.getSelectedText(); //拖动鼠标选取文本。
StringSelection text=new StringSelection(temp);
clipboard.setContents(text,null);
int start=text1.getSelectionStart();
int end =text1.getSelectionEnd();
text1.replaceRange( " ",start,end) ; //从Text1中删除被选取的文本。
}
else if(e.getSource()==paste) //从剪贴板粘贴数据。
{ Transferable contents=clipboard.getContents(this);
DataFlavor flavor= DataFlavor.stringFlavor;
if( contents.isDataFlavorSupported(flavor))
try{ String str;
str=(String)contents.getTransferData(flavor);
text2.append(str);
}
catch(Exception ee){}
}
}
public static void main(String args[])
{ Test win=new Test();
}
}