p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   Java GUI (http://p2p.wrox.com/java-gui-115/)
-   -   How to paste a bitmap into a JPanel? (http://p2p.wrox.com/java-gui/57237-how-paste-bitmap-into-jpanel.html)

AndrewH April 28th, 2007 05:07 AM

How to paste a bitmap into a JPanel?
 
I want to design a class that extends the JPanel class so that I can copy a bitmap image and then right-click on the JPanel and select paste to make the bitmap image appear inside the JPanel.
I have no idea of how to do this in java.
Can anyone give me a simple example of a java program that does this?
Are there any classes in the standard java class library that correspond to bitmaps?

Any pointers will be greatly appreciated.

        AndrewH:)


iamrakesh22 May 1st, 2007 12:19 AM

Hi,
As per i know what you should do is when the user clicks on paste you need to read the data in the clipboard and create an image [ImageIcon class,you can use the constructor which takes byte data as parameter] and use the graphichs object [JPanel.getGraphichs()], call the drawImage() method.

you get information about reading from a clip board at the following URL
http://java.sun.com/j2se/1.3/docs/gu...atransfer.html

Hope it gives some start.

Regards,
Rakesh


All times are GMT -4. The time now is 09:42 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.