Guest User

Untitled

a guest
Apr 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. public void paintComponent(Graphics g){
  2.        
  3.         //Override the default paintComponent method
  4.         super.paintComponent(g);
  5.        
  6.         //Resize the form to get rid of decimal values to make the tick marks accurate since only integers are accepted
  7.        
  8.        
  9.         //Draw the horizontal and vertical axis
  10.         g.drawLine(0, getHeight()/2, getWidth(), getHeight()/2);
  11.         g.drawLine(getWidth()/2, 0, getWidth()/2, getHeight());
  12.        
  13.         //Create a grid scaled to the current size of the window
  14.         for (int i = 1; i < 20; i++){
  15.            
  16.             if (i==10) continue;
  17.            
  18.             //Draw the horizontal ticks
  19.             g.setColor(Color.black);
  20.             g.drawLine(getWidth()/20 * i, getHeight()/2 + 5, getWidth()/20 * i, getHeight()/2 - 5);
  21.            
  22.             //Draw the vertical ticks
  23.             g.drawLine(getWidth()/2 - 5, getHeight()/20 * i, getWidth()/2 + 5, getHeight()/20 * i);
  24.            
  25.         }
  26.     }
Add Comment
Please, Sign In to add comment