JPanel and JFrame coordinate messed up
I am trying to write a game using JPanle and JFrame. I set up a panel inside a frame. When I paint on the panel with a rectangle size of the panel at 0,0. The rectangle shifts up and left for some pixels. How do I fix this problem? I googled and I saw the insets method, but I don't want to use that calculate my coordinate everytime I draw. 

Here are the codes

    public class Game extends JFrame{
	
	public Game(){
		this.getContentPane().setPreferredSize(new Dimension(800,600));  
	    pane p = new pane();
	    this.getContentPane().add(p,BorderLayout.CENTER);
	    p.setPreferredSize(new Dimension(800,600));
	    pack();
	    setResizable(false);
	    setVisible(true);
	    
	
	}
	
	
	public static void main(String[] args){
		new Game();
	}
	
    }


----
    public class pane extends JPanel{

	public pane(){
		
    setDoubleBuffered(false);
    setBackground(Color.black);
    setPreferredSize( new Dimension(800, 600));

    setFocusable(true);
    requestFocus(); 
	}
	
	@Override
	public void paint(Graphics g) {
		g.setColor(Color.white);
		g.fillRect(0, 0, 800, 600);
		g.setColor(Color.black);
		g.fillRect(0, 0, 800, 600);
		
	}
    }

[screen shot link ][1]


  [1]: http://i.stack.imgur.com/R2p03.png
JPanel and JFrame coordinate messed up
===

I am trying to write a game using JPanle and JFrame. I set up a panel inside a frame. When I paint on the panel with a rectangle size of the panel at 0,0. The rectangle shifts up and left for some pixels. How do I fix this problem? I googled and I saw the insets method, but I don't want to use that calculate my coordinate everytime I draw. 

Here are the codes

    public class Game extends JFrame{
	
	public Game(){
		this.getContentPane().setPreferredSize(new Dimension(800,600));  
	    pane p = new pane();
	    this.getContentPane().add(p,BorderLayout.CENTER);
	    p.setPreferredSize(new Dimension(800,600));
	    pack();
	    setResizable(false);
	    setVisible(true);
	    
	
	}
	
	
	public static void main(String[] args){
		new Game();
	}
	
    }


----
    public class pane extends JPanel{

	public pane(){
		
    setDoubleBuffered(false);
    setBackground(Color.black);
    setPreferredSize( new Dimension(800, 600));

    setFocusable(true);
    requestFocus(); 
	}
	
	@Override
	public void paint(Graphics g) {
		g.setColor(Color.white);
		g.fillRect(0, 0, 800, 600);
		g.setColor(Color.black);
		g.fillRect(0, 0, 800, 600);
		
	}
    }

[screen shot link ][1]


  [1]: http://i.stack.imgur.com/R2p03.png