Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Latest commit e916d17 Mar 26, 2019 History
1 contributor

Users who have contributed to this file

import javax.swing.*;
import java.awt.*;
public class ShapesPanel extends JPanel{
private SmartEllipse _ellipse;
private SmartRectangle _rectangle;
private SmartRectangle _diamond;
private Polygon _triangle;
private SmartRectangle _star1;
private SmartRectangle _star2;
public ShapesPanel(){
_ellipse = new SmartEllipse(java.awt.Color.BLUE);
_ellipse.setLocation(200,200);
_ellipse.setSize(50,50);
_rectangle = new SmartRectangle(java.awt.Color.RED);
_rectangle.setLocation(300,250);
_rectangle.setSize(70,100);
_diamond = new SmartRectangle(java.awt.Color.GREEN);
_diamond.setLocation(86, 75);
_diamond.setSize(30,30);
_diamond.setRotation(150);
_star1 = new SmartRectangle(java.awt.Color.GRAY);
_star1.setLocation(500,100);
_star1.setSize(60,60);
_star1.setRotation(150);
_star2 = new SmartRectangle(java.awt.Color.GRAY);
_star2.setLocation(500,100);
_star2.setSize(60,60);
}
public void paintComponent(java.awt.Graphics aBrush) {
super.paintComponent(aBrush);
java.awt.Graphics2D aBetterBrush = (java.awt.Graphics2D) aBrush;
_ellipse.fill(aBetterBrush);
_rectangle.fill(aBetterBrush);
_diamond.fill(aBetterBrush);
_star1.fill(aBetterBrush);
_star2.fill(aBetterBrush);
int[] tr1 = {10, 20, 30};
int[] tr2 = {60, 50, 60};
_triangle = new Polygon(tr1, tr2, 3);
aBrush.setColor(Color.yellow);
aBrush.fillPolygon(_triangle);
}
}