title: Canvas isn't resizing with window in Java?
body: <p>I have a jFrame with a Canvas on it.  When I run my program in Windows XP/Vista and resize the window the canvas resizes proportionately along with the window.</p>
  
  <p>However, in Ubuntu linux, when I compile the same java application and resize my window, the Canvas stays the same size.</p>
  
  <p>What do I need to do to make my Canvas resize with my window in both Windows and Linux?  What is the deal with the discrepancy?</p>
  
  <p><strong>Main.java</strong>  </p>
  
  <pre><code>public class Main {
      public static void main(String[] args)
      {
          JFrame frame = new JFrame("BallBounce");
          frame.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
          frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.Y_AXIS));
  
          BallCanvas ballCanvas = new BallCanvas();
  
          frame.getContentPane().add(ballCanvas);
          frame.getContentPane().add(controlPanel);
          frame.pack();
          frame.setVisible(true);
      }
  }
  </code></pre>
  
  <p><strong>BallCanvas.java</strong></p>
  
  <pre><code>public class BallCavnas extends Canvas {
      public BallCanvas()
      {
          setPreferredSize(new Dimension(640, 400));
          setIgnoreRepaint(true);
  
          ... various gui controls are wired up here
      }
      ... rest of canvas code
  }
  </code></pre>
  
  <hr>
  
  <p>Edit: My source code is zipped up here incase someone wants to take a look:<br>
  <a href="http://www.filedropper.com/ballbounce" rel="nofollow noreferrer">http://www.filedropper.com/ballbounce</a></p>
  
  <p>I've done the suggestions made by Dave Ray, and it still isn't resizing the Canvas?  Remember, it resizes for me fine when I compile this java program and run it in windows.  Only in linux does it does this to me. I'm also running Java 6 Sun 1.6.0.10 JVM, if it matters. </p>
  
  <p><a href="http://img158.imageshack.us/img158/7642/screenshotww0.png" rel="nofollow noreferrer">alt text http://img158.imageshack.us/img158/7642/screenshotww0.png</a></p>
  
  <p>Perhaps my canvas is resizing by my <strong>BufferStrategy/Graphics</strong> aren't resizing ?</p>
  
  <p>Edit 2: From the screenshot, it is definitely set to CENTER:</p>
  
  <pre><code>frame.getContentPane().add(ballCanvas, BorderLayout.CENTER);
  frame.getContentPane().add(controlPanel, BorderLayout.SOUTH);
  </code></pre>
  
  <hr>
  
  <h1>Resolved</h1>
  
  <p>Apparently the "Canvas" was getting resized but I was doing something weird with it's buffer strategy that wasn't allowing IT to be resized.  I fixed it.  Thanks everyone!</p>