//Override the paint() method
publicvoid paint(Graphics g){
  //Downcast the Graphics object to a 
  // Graphics2D object
  Graphics2D g2 = (Graphics2D)g;
  
  //Scale device space to produce inches on 
  // the screen based on actual screen 
  // resolution.
  g2.scale((double)res/72,(double)res/72);
  
  //Translate origin to center of Frame
  g2.translate((hSize/2)*ds,(vSize/2)*ds);
  
  //Draw x-axis
  g2.draw(new Line2D.Double(
                            -1.5*ds,0.0,1.5*ds,0.0));
  //Draw y-axis
  g2.draw(new Line2D.Double(
                            0.0,-1.5*ds,0.0,1.5*ds));

Figure 1