www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: .jayderyu on July 22, 2008, 05:03:51 am
-
blarg
Well got another problem ::)
My Swing JPanel does not display in the contentPane of the applet.
in
init(){
createGuiEdit();
canvas = buffer.enableGLCanvasRenderer();
getContentPane().add(canvas, BorderLayout.WEST);
//add( canvas, BorderLayout.CENTER);
canvas.setVisible( true );
canvas.addMouseListener( input );
canvas.addMouseMotionListener( input );
}
private void createGuiEdit(){
JButton button;
panel = new JPanel(new BorderLayout());
button = new JButton("1x1");
button.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){input.newBox(e); } });
button.setVisible(true);
panel.add(button);
panel.setVisible(true);
getContentPane().add(panel, BorderLayout.EAST);
}
public void paint(Graphics g){
input.update();
buffer.clear(Color.blue); // erase the previous frame
// render the world onto the buffer:
world.renderScene( buffer );
world.draw( buffer );
buffer.update();
buffer.displayGLOnly();
canvas.repaint(); // Paint the canvas onto the applet (hardware mode)
}
do I need to draw the JPanel?
-
Maybe paint has to call super.paint() in this case. I'm not sure...
-
solved, thanks. I tried a few things to get it to paint rather than draw :|.
public void paint(Graphics g){
input.update();
buffer.clear(Color.blue); // erase the previous frame
// render the world onto the buffer:
world.renderScene( buffer );
world.draw( buffer );
buffer.update();
buffer.displayGLOnly();
canvas.repaint();
[b]getContentPane().paintAll(g);[/b]
}