I used Processing for my Bachelor thesis and now i work with it again in the same way.
There i don't use it as Applet but add it to a JFrame. It actual works ok if you get it into it, but the bad problem is that the Applet draws itself all over everthing that is in the Frame to(Menus, InternalFrames)
I wrote the simplest program that shows the Problem.
Code:
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import processing.core.PApplet;
public class InternPFrame extends JFrame {
public InternPFrame() {
this.setSize(400, 400);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
// this needs to be because of the size
this.setVisible(true);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
setVisible(false);
int width = this.getLayeredPane().getWidth();
int height = this.getLayeredPane().getHeight();
//
getContentPane().add(new PA(width, height));
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Test");
JMenuItem menuItem = new JMenuItem("Anything");
menu.add(menuItem);
menuBar.add(menu);
this.setJMenuBar(menuBar);
this.setVisible(true);
}
class PA extends PApplet {
int w, h;
public PA(int w, int h) {
this.w = h;
this.h = w;
init();
}
public void setup() {
size(w, h);
background(0);
}
}
public static void main(String[] args) {
InternPFrame pf = new InternPFrame();
}
}
There is a menu, you can see it without the
Applet
(if you comment
getContentPane().add(new PA(width, height));
out)
Now its very necessary that i can solve the problem. I thought about setting it into another layer that is under the content, but in real there are more JPanel besides the Applet, so this structure will get lost.
Does anybody know, how to set the Applet so it does paint over everything all. Its also possible to turn its drawing temporary off for this
thanks for help,
ramin