/
ClipBoard.java
47 lines (41 loc) · 1.41 KB
/
ClipBoard.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Created on 09-dic-2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.herac.tuxguitar.app.clipboard;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
/**
* @author julian
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ClipBoard{
public ClipBoard(){}
public void addTransferable(final Transferable transferable){
Clipboard sysclip = java.awt.Toolkit.getDefaultToolkit().getSystemClipboard();
sysclip.setContents(transferable, null);
}
public Transferable getTransferable(){
Clipboard sysclip = java.awt.Toolkit.getDefaultToolkit().getSystemClipboard();
try {
return (Transferable) java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().getData(MeasureTransferable.Measure);
}
catch (UnsupportedFlavorException e){ e.printStackTrace(); } // TODO Auto-generated catch block
catch (IOException e){ e.printStackTrace(); }// TODO Auto-generated catch block
return null;
}
public void insertTransfer() throws CannotInsertTransferException{
if(this.isEmpty()){
throw new CannotInsertTransferException();
}
this.getTransferable().insertTransfer();
}
public boolean isEmpty(){
return (this.getTransferable() == null);
}
}