title: draw in Canvas with bufferStrategy
body: <p>I have a code working that shows the evolution of a virtual earth.
  I'm using a JFrame and a bufferedStrategy to draw this world.</p>
  
  <p>I would like to add either on top of the world drawn either next to it, two buttons that can affect the map.</p>
  
  <p>Here is my try :</p>
  
  <pre><code>public class Window extends JFrame{
  
  private BufferStrategy bs;
  private Planete plan;
  private Canvas canvasDroite = new Canvas();
  private JPanel panelGauche = new JPanel();
  final JButton btn = new JButton("Test");
  final JButton btn2 = new JButton("Test 2");
  
  public Window(String name, Planete p){
  this.setTitle(name);                    
  canvasDroite.setSize(new Dimension(Constante.longueur ,Constante.largeur));                 
  this.setSize(1600,900);
  this.setLocationRelativeTo(null);           
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    
  this.setResizable(false);               
  this.setVisible(true);                      
  //this.setLayout(new BorderLayout());
  canvasDroite.createBufferStrategy(3);               
  bs = canvasDroite.getBufferStrategy();              
  frameOrganize();
  plan = p;
  
  }
  
  public void frameOrganize(){
      //panelGauche.add(btn);
      //panelGauche.add(btn2);
      this.add(canvasDroite);
      //this.add("West",panelGauche);
  }
  
  public void draw()
  {
  Graphics2D g = null; //pointeur de l'outil de dessin
  do{
      try{
      g = (Graphics2D)bs.getDrawGraphics();
      if(plan != null)
          plan.draw(g);
      }
      finally
      {
          g.dispose(); 
      }
      bs.show(); 
  } while (bs.contentsLost()); 
  }
  
  }
  </code></pre>
  
  <p>When there is only the frame everything work</p>
  
  <p>I tried to create the bufferedStrategie in a JPanel but it doesn't work, I only use g.drawLine() ( when I do plan.draw(g)) to change the map so I tried to drop the bufferStrategy and draw directly into the JPanel but I didn't succeed</p>
  
  <p>And my try with the Canvas doesn't work either, the window appear but nothing is drawn.</p>
  
  <p>I also tried to use paint() and repaint() for Canvas and JPanel.    </p>
  
  <p>PS : I looked many post but I've never seen when is used the paint(Graphics g) method for a JPanel to start the painting, that's why I use bufferstrategy, It's easier in my point of view.                                       </p>