I'm trying to embed a PApplet in a JScrollPane within a JFrame, so that I can properly work on sketches that are larger than my screen. I tried embedding the PApplet in a fixed size JPane, but I can't get that to render properly, and when I simply display the PApplet within the JScrollPane, the PApplet ignores whatever size I set it at and instead assumes whatever size the JFrame is.
Has anyone else tried to do anything like this successfully? I'm open to any ideas, I'm just trying to create some type of scrolling capability.
controlP5 might be an option, but I'm working in a larger framework created in Java and I'm trying to maintain a consistent look and feel.
Why are you using a JInternalFrame rather than a JPanel? (I'm a Swing n00b, so take the question with a grain of salt).
I'm trying something similar, although I am working on a more elaborate Swing interface, with a scrollable panel in the interface. I'm extending JPanel and adding a p5 sketch, like in Irags Kite: http://wiki.processing.org/w/Swing_JSliders
My problem is I can't get the p5 sketch to sit behind the viewport. The scrollbars work fine, but the z-index is all screwy. Any ideas?
Actually the approach you're describing is the first one I tried, but I had the same error as you.
From what I can tell, JPanel exhibits some bizarre behavior when you embed an Applet inside it. I don't think it was ever designed to handle an embedded Applet. My next thought was JFrame, but since you cannot embed a JFrame within a JPanel, I decided to go with JInternalFrame.
I'll post my code as soon as I clean it up a bit.
Oh, one other note is that I switched from JScrollPane to ScrollPane because there were again some bizarre rendering issues and I didn't feel like exploring the reasons why. It could probably be made to work though with a bit of hacking.
ok, I think I get it... you're stripping a JInternalFrame and treating as a JPanel? I can't run your code obviously, but are you having good results? Does the JInternalFrame occlude other lightweight components, or does it play better? Do you have any screenshots?
it's interesting, certainly. In the meantime, I decided to just avoid scrollbars entirely, unless I make them in P5. But your experiment is good food for thought... and later on I might reconisder.
Yeah that's pretty much what I'm doing. And yeah it seems pretty solid and lets me have multiple scalable sketches open at the same time.
I would think you'd be able to run it if you changed Canvas to whatever your sketch is named. You just have to put this in a separate class written in Java. (I'm working in Eclipse... I don't think I made that clear, sorry.)
All my lightweight components are in other heavyweight containers so I haven't tested that... you're not trying to embed swing components within Processing are you? Cause that's a recipe for a headache. I don't think it can be done successfully.
Here are some screen shots of the various states as well as how it interacts with my (mostly) placeholder menu bar.