Orlando15767
asked on
implementing cut and paste
how can i implement cut and paste to the system clipboard in a simple painter program?
ASKER
I tried putting the methods into the cut method created from implementing cutable and I was recieving errors at line marked **
public void cut(ActionEvent evt) {
** public static Image getClipboard() {
Transferable t = Toolkit.getDefaultToolkit( ).getSyste mClipboard ().getCont ents(null) ;
try {
if (t != null && t.isDataFlavorSupported(Da taFlavor.i mageFlavor )) {
Image text = (Image)t.getTransferData(D ataFlavor. imageFlavo r);
return text;
}
} catch (UnsupportedFlavorExceptio n e) {
} catch (IOException e) {
}
return null;
}
}
Syntax error, insert ";" to complete BlockStatements
Syntax error on token(s), misplaced construct(s)
public void cut(ActionEvent evt) {
** public static Image getClipboard() {
Transferable t = Toolkit.getDefaultToolkit(
try {
if (t != null && t.isDataFlavorSupported(Da
Image text = (Image)t.getTransferData(D
return text;
}
} catch (UnsupportedFlavorExceptio
} catch (IOException e) {
}
return null;
}
}
Syntax error, insert ";" to complete BlockStatements
Syntax error on token(s), misplaced construct(s)
Is the above mentioned code being used in program..
As it seems to have a method in a method
As you are missing some } somewhere
The below mentioend method is OK
public static Image getClipboard() {
Transferable t = Toolkit.getDefaultToolkit( ).getSyste mClipboard ().getCont ents(null) ;
try {
if (t != null && t.isDataFlavorSupported(Da taFlavor.i mageFlavor )) {
Image text = (Image)t.getTransferData(D ataFlavor. imageFlavo r);
return text;
}
} catch (UnsupportedFlavorExceptio n e) {
} catch (IOException e) {
}
return null;
}
}
As it seems to have a method in a method
As you are missing some } somewhere
The below mentioend method is OK
public static Image getClipboard() {
Transferable t = Toolkit.getDefaultToolkit(
try {
if (t != null && t.isDataFlavorSupported(Da
Image text = (Image)t.getTransferData(D
return text;
}
} catch (UnsupportedFlavorExceptio
} catch (IOException e) {
}
return null;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://javaalmanac.com/egs/java.awt.datatransfer/ToClipImg.html