Reputation: 121
I'm trying to create a simple interface that shows a folder full of short avi's as buttons in Processing 3.x. I would like to display it as the file icon from the windows explorer window and start it running when pressed.
All the answers that I am finding require the use of Java Swing. Swing does not work inside of processing.
What I have... A simple button list of the file names in the directory that works just fine.
Why processing. Because that's what i have available at the moment, and runs on the minimal hardware that's required, using a barely modified version of movie2serial to drive a pair of teensy 3.1 boards to light up a simple led strip matrix.
The sample Processing file, movie2serial does an excellent job of driving the teensy, and I don't have a lot of time available to learn everything about getting a full java app completed to do it.
To be clear, I am asking if there is a way to get the system icon for a file, specifically in Windows (7+), using processing and standard java libraries that are available in processing, not with Swing, because that doesn't appear to be an option.
Thanks!
Upvotes: 2
Views: 77
Reputation: 42174
You're correct that you can't display Swing directly in Processing. But you can convert Swing data into data that Processing can use.
Step 1: Use Java to get a BufferedImage
of the file's icon. You might have to go through some intermediate steps, such as converting an Icon
into a BufferedImage
. Google is your friend, but here are some starting points:
Step 2: Convert that BufferedImage
into a PImage
that you can use. Note that you can't display the BufferedImage
directly, but you can still interact with it using Processing code. Again, Google is your friend here, but here are some more starting points:
Another option would be to use Processing as a Java library, and then split your view into the Processing canvas and the rest of the GUI. Then you could use Swing (or better yet, JavaFX) to show the icons.
If you get stuck (especially on the second step), then that would be a reasonable follow-up question. Don't forget the MCVE!
Upvotes: 2