简体   繁体   中英

Allow a Java Application User to import images to be displayed within the program

Basically, the functionality I want is for a user to use a file choose to import an image into the program and then that program be able to display that image. I then want this image to be able to be serialized and unserialized as the program is stored between launches.

As a sub question, whats the best way to display multiple images, is there a build in component or something similar I will I have to make something.

Thanks

Once you have the image loaded into an Image object, just store that as a member of the class that wants to show it, and use drawImage() during that component's paintComponent() method.

If you use an ImageIcon, then as given in this question:

How to best serialize a java.awt.Image?

you have your technique for serialization (note the warnings).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM