thorax232

Java Drawing Lines Example

Jul 21st, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. import java.awt.*;
  2. import javax.swing.*;
  3.  
  4. // Creating panel for grid
  5. public class GridPanel extends JPanel
  6. {
  7.     protected void paintComponent(Graphics g)
  8.     {
  9.         super.paintComponent(g);
  10.         for(int i = 1; i <=2; i++)
  11.         {
  12.             g.setColor(Color.BLUE);
  13.             g.drawLine(0, i * (getHeight() / 3), getWidth(), i * (getHeight() / 3));
  14.             g.setColor(Color.RED);
  15.             g.drawLine(i * (getWidth() / 3), 0, i * (getWidth() / 3), getHeight());
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment