Cut and paste images

E

Esteban

Hi.
I need help very urgent.
I need to paste an image (from autocad) to a Java frame, using copy & paste.
And after that, save it in a database (oracle)
It is possible ??

Thanks in advance.
Esteban
 
T

Tor Iver Wilhelmsen

I need to paste an image (from autocad) to a Java frame, using copy & paste.
And after that, save it in a database (oracle)
It is possible ??

Yes.
 
A

ak

I need help very urgent.
I need to paste an image (from autocad) to a Java frame, using copy & paste.
And after that, save it in a database (oracle)
It is possible ??
yes.

//first get system clipboard
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

//get transferable
Transferable transferable = clipboard.getContents();

//check data
DataFlavor[] flavors = transferable.getTransferDataFlavors();

//choose right flavor (something with "java/image" mime type? - sorry I
forgot it - try to print mime types of all DataFlavors)
//and get object
Object o = transferable.getTransferData(flavor);
 
S

Sudsy

Esteban said:
Hi.
I need help very urgent.
I need to paste an image (from autocad) to a Java frame, using copy & paste.
And after that, save it in a database (oracle)
It is possible ??

Thanks in advance.
Esteban

Should be possible. Two challenges:
- reading the data which was stored on the clipboard (don't know
what format it will be in)
- saving the image to a BLOB
(if you're talking about just an image)
Much more difficult would be if you wanted to go the other
way, i.e. retrieve an image from the database and paste it
back into AutoCad. You might have to use DWF and a viewer.
 
T

Tor Iver Wilhelmsen

ak said:
//choose right flavor (something with "java/image" mime type? - sorry I
forgot it - try to print mime types of all DataFlavors)

On my 1.4.x, the only DataFlavor returned for an image is
"image/x-java-image; class=java.awt.Image". The class of the object
returned is java.awt.image.BufferedImage.
 
A

ak

On my 1.4.x, the only DataFlavor returned for an image is
"image/x-java-image; class=java.awt.Image". The class of the object
returned is java.awt.image.BufferedImage.
I suppose this is exactly what you need
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top