We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi Im trying to make an image selector, which can select images from any destination on the computer. Im trying to use the JFileCHooser.
void chooser() {
JFileChooser chooser = new JFileChooser();
selected = loadImage("chooser.showOpenDialog(aComponent)");
image(selected, width/2,height/2);
}
This is what I tried so far, but it won't work :/ any ideas?
Answers
you can use processing's own command
http://www.processing.org/reference/selectInput_.html
you can also just do it like this
Hi Chrisir,
Your answer here is fantastic! I have one question, can it be possible to set the size of the sketch based on the size of the image? I have tried some different ways, still no clue. I even put the setup function inside the
if (selected!=null)
and it was funny to find that it cause and infinite loop ;PThanks
I don't know how to do this.
In fact, under the hood there are different inits running for processing when doing size().
The general idea is that size is the 1st line in setup().
I tried but I couldn't do it otherwise.
You could either scale your images on the hard drive as you need them (all the same size) or even resize them with processing in your program (only in the RAM, not on hard drive).
You could set the image in a region of your sketch and leave space for scren buttons or some help texts...
maybe there are solutions, sure
maybe using frames / robots or so....
Hi Chrisir!
thanks for taking the time to think about this... I am trying to find a way to adapt the size of the sketch dynamically because I wont know the size of the picture to be use in the program... Thank you very much for your sugestions
Regards