1 package com.quikj.application.utilities.sqlc; 2 3 import java.io.*; 4 import java.awt.datatransfer.*; 5 6 public class TextClipBoard 7 { 8 private TextClipBoard() 9 { 10 instance = this; 11 } 12 13 public static TextClipBoard Instance() 14 { 15 if (instance == null) 16 { 17 new TextClipBoard(); 18 } 19 return instance; 20 } 21 22 public void copyToClipBoard (String text) 23 { 24 if (text.length() > 0) 25 { 26 StringSelection selection = new StringSelection (text); 27 java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents (selection, selection); 28 } 29 } 30 31 public String getClipBoardContent() 32 { 33 Transferable trans = java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().getContents (this); 34 35 try 36 { 37 return new String ((String )trans.getTransferData (DataFlavor.stringFlavor)); 38 } 39 catch (UnsupportedFlavorException ex1) 40 { 41 return new String (""); 42 } 43 catch (IOException ex2) 44 { 45 return new String (""); 46 } 47 } 48 49 private static TextClipBoard instance = null; 50 } 51 52 53 54 55 | Popular Tags |