Advertisement
Guest User

Example

a guest
Sep 27th, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. import java.awt.*;
  2. import javax.swing.*;
  3.  
  4. public class Rectangle extends JPanel {
  5.     JFrame frame;
  6.  
  7.     public void fireUpScreen() {
  8.         frame = new JFrame();
  9.         frame.setVisible(true);
  10.         frame.setSize(600,600);
  11.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  12.         frame.add(this);
  13.     }
  14.  
  15.     public void paintComponent(Graphics g) {
  16.         g.setColor(Color.BLUE);
  17.         g.fillRect(0,0,200,100);
  18.     }
  19.  
  20.     public static void main(String[] args) {
  21.         Rectangle go = new Rectangle();
  22.         go.fireUpScreen();
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement