Author Topic: Swing/JApplet problem, no panel  (Read 2722 times)

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Swing/JApplet problem, no panel
« 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?
« Last Edit: July 22, 2008, 09:33:14 am by .jayderyu »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Swing/JApplet problem, no panel
« Reply #1 on: July 22, 2008, 03:45:43 pm »
Maybe paint has to call super.paint() in this case. I'm not sure...

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Re: Swing/JApplet problem, no panel - (solved)
« Reply #2 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]
}