title: Java Graphics Update/Repaint Graphic
body: <p>I'm trying to work with the Java paint
  utility and it's been a bit of a hassle.</p>
  
  <p>I'm trying to do something which I assume is quite basic.
  I'm drawing a square Graphic to a JPanel and then trying
  to move it using repaint</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.image.*;
  
  public class testGui {
  
     static gui      gc_gui;
     static int      gv_x;
     static int      gv_y;
  
     public static void main(String[] args) {
  
        gc_gui = new gui();
        gv_x = 50;
        gv_y = 50;
  
        gc_gui.cv_frame.setVisible(true);
  
     }
  
     public static class gui {
  
        JFrame    cv_frame;
        content   cv_content;
  
        public gui() {
  
           cv_frame = new JFrame();
           cv_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           cv_frame.setTitle("Test GUI");
           cv_frame.setSize(600, 400);
           cv_frame.setLayout(new FlowLayout());   
  
           cv_content = new content();
           cv_content.setBackground(Color.Black);
           cv_content.setPreferredSize(new Dimension(500, 300));
           cv_frame.add(cv_content);
  
           gv_x = 0;
           gv_y = 0;
  
           cv_content.update();
  
        }
  
     }
  
     public static class content extends JPanel {
  
        public void paint(Graphics graphic) {
           super.paint(graphic);
           draw(graphic);
        }
  
        public void update() {
           super.repaint();
        }
  
        public void draw(Graphics graphic) {
           Graphics2D graphic2D = (Graphics2D) graphic;
           graphic2D.setPaint(Color.Red);
           graphic2D.fillRect(gv_x, gv_y, 100, 100);
        }
  
     }
  
  }
  </code></pre>
  
  <p>I don't know why the call to the update function isn't doing
  anything though.</p>
  
  <p>It draws the square at 50x and 50y, the sets it to 0x and 0y
  immediately and then when I call repaint I expected it to
  be moved to it's new coordinates although it's still at
  50x and 50y.</p>
  
  <p>Why is this?</p>