DataObject.getData

Overview | Methods | This Package | All Packages

DataObject.getData

Retrieves the data associated with the specific data format.

Syntax

public Object getData( String format )

public Object getData( Class format )

Parameters

format

A String object or class that represents the format of the data to retrieve.

Return Value

Returns an object that represents the data associated with the specific format.

Remarks

Use the getData method to retrieve the data stored in the Data object. You can define the format that the data should be stored in using either a String object that defines that data type or the class for the data format. You can use the fields of the DataFormats class to define the proper data format. To determine the format of the data before calling this method, use the getDataPresent method.

The following code demonstrates how to use the getData method to retrieve data that is currently on the Clipboard. It also shows how to use the methods of the DataObject interface to assign an Edit control's text with the contents of the DataObject.

    private void mnuPaste_click(Object sender, Event e) {
    		DataObject d = Clipboard.getDataObject();
	    	if (d.isDataPresent(String.class) {
    		    edit1.setText((String)d.getData(String.class));
	    	}
    }

See Also   IDataObject, setData