Advertisement
cd62131

Graphics Demo

Feb 18th, 2014
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.67 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Dimension;
  3. import java.awt.Graphics;
  4. import javax.swing.JFrame;
  5. import javax.swing.JPanel;
  6.  
  7. public class Demo {
  8.   public static void main(String[] args) {
  9.     JFrame f = new JFrame("Demo");
  10.     f.setSize(new Dimension(500, 500));
  11.     JPanel p = new JPanel() {
  12.       private static final long serialVersionUID = 1L;
  13.  
  14.       @Override
  15.       public void paintComponent(Graphics g) {
  16.         g.setColor(Color.BLACK);
  17.         g.drawLine(125, 0, 125, 80);
  18.         g.drawLine(250, 0, 250, 80);
  19.         g.drawLine(375, 0, 375, 80);
  20.         g.drawLine(0, 80, 500, 80);
  21.       }
  22.     };
  23.     f.add(p);
  24.     f.setVisible(true);
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement