Loading...
Logo
Processing Forum
Hi,

I just have a few questions on Processing and thought it would be best to to just throw them all in one post:

1: Is it possible to reference methods as variables like is done in JavaScript 
i.e if(button.type=="close"){ button.action() = hide_parent(); }

2. Is there any way to read in pasted images (like is done in photoshop and similar programs?

3. is it possible to save a screenshot as an image file?



Thanks

Replies(4)

1. No, not that I've ever seen.

2. Yes, but it is dark magic. See this.

3. Yes. See save(). Or if you want a screenshot of the whole screen (which is also dark magic), look into this. And the Robot class.
Thanks for the reply!

One more question:
4. I'm struggling with using showOpenDialog() when calling it from a button. 
    I have it in a void method called "open_file()".
   If I call this method from setup it works fine but when I call it from clicking the button it gets stuck on the
  int returnVal = fc.showOpenDialog(this);  line
  I have the method placed outside the button's class so the "this" is referring to the main parent

Any Ideas?
1) Not really, but there was a recent thread on how to do it in Java. BTW, string comparison isn't done with == in Java.
2) You already asked the question in a specific thread...
3) tfguy44 answered...
4) Don't mix Swing / AWT and Processing. See selectInput() or selectFolder() that correctly implement showOpenDialog().
Brilliant!

Didn't know about the selectInput() class!

Cheers