Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- public class Peach extends JPanel{
- // Variables
- public void paintComponent(Graphics g){
- super.paintComponent(g);
- this.setBackground(Color.WHITE);
- // Line
- g.setColor(Color.BLUE);
- g.drawLine(10, 25, 200, 45);
- // Rectangle
- g.setColor(Color.RED);
- g.drawRect(10, 55, 100, 30);
- // Oval
- g.setColor(Color.GREEN);
- g.fillOval(10, 95, 100, 30);
- // 3D Rectangle
- g.setColor(Color.ORANGE);
- g.fill3DRect(10, 160, 100, 50, true);
- }
- // Main Function
- public static void main(String[] args){
- JFrame f = new JFrame("JFrame's title");
- f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- Peach p = new Peach();
- p.setBackground(Color.WHITE);
- f.add(p);
- f.setSize(500, 300);
- f.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement