graphics.clipboard
Class ClipBoardUtils

java.lang.Object
  extended by graphics.clipboard.ClipBoardUtils

public class ClipBoardUtils
extends java.lang.Object


Nested Class Summary
static class ClipBoardUtils.ClipboardAction
           
 
Constructor Summary
ClipBoardUtils()
           
 
Method Summary
static void captureScreen()
           
static void convertClipboardToRtf()
           
static void copyImageAndTextToClipboardAsRtf(java.awt.image.BufferedImage image, java.lang.String caption)
          This will copy, using RTF, to the clipboard.
static void copyToClipboardAsRtf(java.awt.Rectangle r)
           
static java.io.Reader createClipboardReader()
           
static java.io.Writer createClipboardWriter()
           
static java.awt.Image getClipBoardImage()
           
static java.lang.Object getJPeg(java.awt.Rectangle screenRect)
           
static java.lang.String getTextFromClipboard()
           
static java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
           
static boolean isContentAvailable()
           
static void main(java.lang.String[] args)
           
static void saveTextToClipboard(java.lang.String data)
           
static boolean setContents(java.awt.Image image, java.awt.datatransfer.ClipboardOwner owner)
          Sets the current contents of the clipboard to the specified image and registers the specified clipboard owner as the owner of the new contents
static boolean setContents(javax.swing.JComponent c, java.awt.datatransfer.ClipboardOwner owner)
           
static boolean setContents(java.lang.String content, java.awt.datatransfer.ClipboardOwner owner)
          Sets the current contents of the clipboard to the specified StringBuffer and registers the specified clipboard owner as the owner of the new contents
static boolean setContents(java.awt.datatransfer.Transferable contents, java.awt.datatransfer.ClipboardOwner owner)
          Sets the current contents of the clipboard to the specified transferable object and registers the specified clipboard owner as the owner of the new contents.
static boolean setImageContents(java.awt.Component comp, java.awt.datatransfer.ClipboardOwner owner)
          Sets the current contents of the clipboard to an graphical image of the component and registers the specified clipboard owner as the owner of the new contents This method isn't just called setContents(Component comp, ClipboardOwner owner) because Components might implement the Transferable Interface themselves which would lead to confusion with the setContents(Transferable trans,ClipboardOwner owner)-method.
static void setRtfContents(java.io.ByteArrayOutputStream baos, java.awt.datatransfer.ClipboardOwner owner)
          Fills the clipboard with a RTF-Transferable.
static void transparentDialogToClipBoard()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClipBoardUtils

public ClipBoardUtils()
Method Detail

captureScreen

public static void captureScreen()

copyToClipboardAsRtf

public static void copyToClipboardAsRtf(java.awt.Rectangle r)
                                 throws java.awt.AWTException,
                                        java.io.IOException,
                                        com.lowagie.text.DocumentException
Throws:
java.awt.AWTException
java.io.IOException
com.lowagie.text.DocumentException

getTextFromClipboard

public static java.lang.String getTextFromClipboard()

createClipboardReader

public static java.io.Reader createClipboardReader()

createClipboardWriter

public static java.io.Writer createClipboardWriter()

isContentAvailable

public static boolean isContentAvailable()

saveTextToClipboard

public static void saveTextToClipboard(java.lang.String data)

getClipBoardImage

public static java.awt.Image getClipBoardImage()
                                        throws java.awt.datatransfer.UnsupportedFlavorException,
                                               java.io.IOException
Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException

getJPeg

public static java.lang.Object getJPeg(java.awt.Rectangle screenRect)
                                throws java.awt.AWTException,
                                       java.io.IOException
Throws:
java.awt.AWTException
java.io.IOException

setContents

public static boolean setContents(java.lang.String content,
                                  java.awt.datatransfer.ClipboardOwner owner)
Sets the current contents of the clipboard to the specified StringBuffer and registers the specified clipboard owner as the owner of the new contents

Parameters:
content - a string to be placed on the clipboard
owner - a class
Returns:
boolean false if exception occurred

setContents

public static boolean setContents(java.awt.datatransfer.Transferable contents,
                                  java.awt.datatransfer.ClipboardOwner owner)
Sets the current contents of the clipboard to the specified transferable object and registers the specified clipboard owner as the owner of the new contents. Shows warning message if an exception occured

Parameters:
contents - transferable contents
owner - listener for lost ownership
Returns:
boolean false if an exception occured

setContents

public static boolean setContents(java.awt.Image image,
                                  java.awt.datatransfer.ClipboardOwner owner)
Sets the current contents of the clipboard to the specified image and registers the specified clipboard owner as the owner of the new contents

Parameters:
image -
owner -
Returns:
boolean false if exception occurred

setContents

public static boolean setContents(javax.swing.JComponent c,
                                  java.awt.datatransfer.ClipboardOwner owner)

setImageContents

public static boolean setImageContents(java.awt.Component comp,
                                       java.awt.datatransfer.ClipboardOwner owner)
Sets the current contents of the clipboard to an graphical image of the component and registers the specified clipboard owner as the owner of the new contents This method isn't just called setContents(Component comp, ClipboardOwner owner) because Components might implement the Transferable Interface themselves which would lead to confusion with the setContents(Transferable trans,ClipboardOwner owner)-method.

Parameters:
comp -
Returns:
boolean false if exception occurred

setRtfContents

public static void setRtfContents(java.io.ByteArrayOutputStream baos,
                                  java.awt.datatransfer.ClipboardOwner owner)
Fills the clipboard with a RTF-Transferable.

Parameters:
baos - - an rtf in form of ByteArrayOutputStream

copyImageAndTextToClipboardAsRtf

public static void copyImageAndTextToClipboardAsRtf(java.awt.image.BufferedImage image,
                                                    java.lang.String caption)
                                             throws java.io.IOException,
                                                    com.lowagie.text.DocumentException
This will copy, using RTF, to the clipboard. The image will be able to paste into word, from a mac, AND can be viewed under windows without the Tiff decompressor error needed.

Parameters:
image - The bufferedImage to be viewed
caption - A plaintext caption that will apear under the image
Throws:
java.io.IOException
com.lowagie.text.DocumentException

convertClipboardToRtf

public static void convertClipboardToRtf()
                                  throws java.awt.datatransfer.UnsupportedFlavorException,
                                         java.io.IOException,
                                         com.lowagie.text.DocumentException
Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException
com.lowagie.text.DocumentException

transparentDialogToClipBoard

public static void transparentDialogToClipBoard()

getTransferDataFlavors

public static java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()

main

public static void main(java.lang.String[] args)