Spread the love

Commonly Used Clipboard Objects in Testing

Spread the love

Clipboard Objects in Testing

ClipBoard class is used for a Transferable object and can be used for Cut,Copy,Paste operation.

This is used to get or transfer/send information via Clipboard Mostly Java has two types of clipboards. Local and system.

Local clipboards are only available inside the virtual machine that  your applet or application is running. However, unlike some
operating systems that limit you to only one clipboard, Java allows  you to have as many local clipboards as you desire. Accessing a particular local clipboard is as easy as referring to it by name.System clipboards are directly linked with the peer operating system, allowing your application to transfer information among

any applications running under that operating system. One  disadvantage of using the system clipboard is that you can only
transfer text data. Other types of objects are not supported  by the system clipboard. With any luck, this issue will be addressed in  the next release of the JDK.


ClipboardClassDeals with everything that is a transferable
ClipboardOwnerInterfaceEvery class that deals with the clipboard must implement this interface. This interface is used to notify when the data originally placed in the clipboard has been overwritten
DataflavorClassRepresents all the data types that transferable support
StringSelectionClassOne type of transferable that is supplied with Java
TransferableInterfaceWrapper to objects passed to the clipboard
ExceptionClassException thrown by transferable for an unsupported data flavor
The clipboard Class:
String getName ()Get the name of the clipboard
void setContents (Transferable, ClipboardOwner)Set the content of the clipboard along with owner object
Transferable getContent (Object)Get the content of the clipboard in the form of a Transferable object. The object passed as a parameter is the owner
READ  How To Configure Jenkins With Selenium Projects
READ  Access Specifiers Concept Simplified in Java


To access the system clipboard:
Clipboard clip=getToolkit().getSystemClipboard();
The ClipBoard Owner Interface:
Its sole function is to inform the owner of the clipboard when his or her data is being overwritten by someone else. It can also signal an application when to release a resource associated with the data. In a real application, the lostOwnership method could be used to set a flag that informs your application about the availability of the data in the clipboard. Microsoft Word, while not written in Java, is a good example of this mechanism at work in an application. Whenever you put something in the clipboard within Word and then quit, a dialog box appears informing you that data is in the clipboard. You will then be asked if you want to leave the data in the clipboard.


The DataFlavor class
The DataFlavor class is used to represent the type of an object. You’re not limited to one data flavor (or type) per object. And, like us, your objects can have multiple personalities! For example, an image class can be represented as a Java class or as an array of bits (GIF, JPEG, and so on). In reality, a DataFlavor class is a wrapper to a MIME type. The MIME standard is extensive, hence there are virtually no limits to the data that can be transferred to the clipboard.


boolean equals (DataFlavor)Test if the DataFlavor supplied is equal to the DataFlavor represented by this class
String getHumanPresentableName ()Return the human representable name for the format that this DataFlavor represents
void setHumanPresentableName (String)Set the human representation name for this DataFlavor
String getMimeType ()Get the MIME type string represented by this DataFlavor
Class getRepresentationClass ()Return the Class that represents this class
READ  How To Solve "Java SE Platform binary stopped working" Problem in Selenium?
READ  What is User Acceptance Testing(UAT)?


The Transferable interface
The Transferable interface must be implemented by all classes that you want to send to the clipboard, hence the Clipboard class will only understand classes that have been wrapped by the Transferable interface. The Transferable interface is comprised of three methods:
Transferable interface

DataFlavor getTransferDataFlavor ()Return an array of DataFlavor that represents the object
boolean isDataFlavorSupported (DataFlavor)Test if the DataFlavor supplied is supported
Object getTransferData (DataFlavor)Return the object represented by the supplied DataFlavor


Spread the love
Animesh Chatterjeehttps://techtravelhub.com/
I am the founder and owner of the blog - TechTravelHub.com, always love to share knowledge on test automation,tools,techniques and tips.I am a passionate coder of Java and VBScript.I also publish articles on Travel ideas and great honeymoon destinations.Apart from these, I am a gear-head,love to drive across India. I have shared lots of articles here on How to travel several parts of India.Customization of cars aka car modification is my another hobby.Get in touch with me on ani01104@gamil.com

Related Articles

Learn What Primary Tools For Test Automation

Primary Tools For Test Automation According to the Gartner report Magic Quadrant...


  1. Very great post. I simply stumbled upon your blog and wanted to say that I have really enjoyed browsing your weblog posts. After all I’ll be subscribing on your feed and I am hoping you write again very soon!


Please enter your comment!
Please enter your name here

Recent Posts

Super Keyword in Java Simplified

Super Keyword Super Keyword in Java Simplified: Java defines a special...

Learn Object Repository in UFT in An Efficient and Fast Manner

Object Repository in UFT The post will cover the following...

Learn What Primary Tools For Test Automation

Primary Tools For Test Automation According to the Gartner report...


Spread the love