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{
- public void paintComponent(Graphics g){
- super.paintComponent(g);
- this.setBackground(Color.WHITE);
- g.setColor(Color.BLUE);
- g.fillRect(25, 25, 100, 30);
- g.setColor(new Color(132, 13, 13));
- g.fillRect(25, 65, 100, 30);
- g.setColor(Color.GREEN);
- g.drawString("This is a text", 25, 120);
- }
- // Main Function
- public static void main(String[] args){
- JFrame frame = new JFrame("JFrame's title");
- frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- Peach p = new Peach();
- frame.add(p);
- frame.setSize(500, 300);
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement