PDA

View Full Version : open pictures through java GUI



raac
October 9th, 2011, 07:52 PM
Hello guys, let say I have a JList displayed. It contains a bunch of pictures names.
Is it possible to double click on them and open up the correspondent picture?

I'm guessing the pictures need to be placed on the current directory where java is running, but I don't know if I'm able to open them through java GUI.

cgroza
October 9th, 2011, 10:24 PM
I am sure you can. Take a look at this:
http://stackoverflow.com/questions/299495/java-swing-how-to-add-an-image-to-a-jpanel

You will have to handle the List click events, and do the necessary actions.

ofnuts
October 9th, 2011, 10:26 PM
Hello guys, let say I have a JList displayed. It contains a bunch of pictures names.
Is it possible to double click on them and open up the correspondent picture?
Depends what you call "open up". Is it "display" or "read the data in the file"? Both can be done, the first being a bit more complicated, depending on what you really want to do.


I'm guessing the pictures need to be placed on the current directory where java is running, but I don't know if I'm able to open them through java GUI.Not necessarily, it depends a lot on how you got the names. Maybe you can use a default directory, or even ask the user where the pictures are on the disk. But on the whole, in an application, you either get the full path to the pictures, or the picture are part of your application (in Java, they would be "resources"), in which case they are found by the classloader.