We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have a JPanel where I want to run a processing sketch which performs spectrum analysis. I have tried psurface but it is giving me errors. Any Idea how to do it? Hope I will get answers this time. Thanks in advance
Answers
https://forum.Processing.org/two/discussions/tagged/jpanel
AFAIK it is not possible to do this with Processing V3.
In theory it might be possible to do with Processing 2.2.1
EDIT
You would have to create a class that extends JPanel which has a field/attribute of type PApplet.So I have to go for processing 2? Any link or material on how to do it? @quark
I have no link or material on how to do it, my only experience comes from creating multiple windows for G4P.
I assume that you are using an IDE other than Processing e.g. Eclipse or Netbeans. What are you using?
There are some things you would need to consider
1) You would need to download Processing 2.2.1 and locate the core.jar file. You will need to link your project to it.
2) Create a new class (e.g.
MyPapplet
) that extends PApplet so you can override the normal Processing methods e.g.setup()
,draw()
etc.3) Use a BorderLayout for the JPanel and add
papplet
to the CENTER to allow for resizing. If that causes problems use a FlowLayout.That is how I would start. I can't promise that it will work so I suggest you create a new simple project to try these ideas out and then apply any solution to the spectrum analysis sketch.
WARNING
I did say
so what I suggest here might not work, but whatever happens it will be very challenging.
https://forum.Processing.org/two/discussion/12234/get-values-from-a-jdialog
https://forum.Processing.org/two/discussion/13175/do-whille-is-not-working-how-it-suppose-to
Here is my code in java where I took a frame & inside a frame I took a psurface..And within that surface I tried to run a processing sketch to perform spectrum analysis. But its giving me errors.Like these:
If these codes can help..@GoToLoop @quark I would like to mention that psurface is working in jframe. Like the image below. But mine is not working.
TIA
In the code below I managed to get the sketch inside a JPanel but I also got the following error messages.
I always get lines 1-13 which I believe to be an Osx problem because Processing is trying to set the dock icon.
Notice line 13 - the sketch path hasn't been set :(
Once I added the Minim code I got the rest of the message.
There appears to be two problems line 16 and line 19 both caused by Minim and I suspect both caused by the fact the sketch path has not been set. Minim like most contributed libraries assume that the sketchPath is set and will attempt to use it.
I don't know what the solution is but if you find one please post it here.
The Sketch
https://forum.Processing.org/two/discussions/tagged/--sketch-path
I tried processing 2.2.1 as you guyz suggested and its done now.. I made a class which extends PApplet..Did everything I need there in setup and draw.. I made another class which has main function in it..I declared an object from the previous class..started the applet...I took a Jpanel..Added the applet to Jpanel..Then took a JFrame and added the Jpanel to the JFrame...Its looking good now.
But I have some issues here...From the main class, I tried
Applet.gesize().width
But its not giving me the actual size..I gave width = 552 and width = 230 in the size function..But its giving me width = height = 100 from Main Class..So I had to manually give the width and height of the JFrame..I want to recover it..@quark @GoToLoop
If you read the comments in lines 14-16 of my code you will see I had the same problem. The problem is you don't know which is going to be returned so it is better to keep track of the values yourself.