www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: .jayderyu on July 22, 2008, 05:03:51 am

Title: Swing/JApplet problem, no panel
Post 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.



Code: [Select]

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?
Title: Re: Swing/JApplet problem, no panel
Post by: EgonOlsen on July 22, 2008, 03:45:43 pm
Maybe paint has to call super.paint() in this case. I'm not sure...
Title: Re: Swing/JApplet problem, no panel - (solved)
Post by: .jayderyu on July 22, 2008, 04:19:17 pm
solved, thanks. I tried a few things to get it to paint rather than draw :|.


Code: [Select]
  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]
}