Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3.  
  4. public class Shape extends JComponent {
  5.  
  6. public void draw()
  7. {
  8. rect = new Rectangle(xUpperLeftCorner, yUpperLeftCorner, width, height);
  9. this.repaint();
  10. }
  11.  
  12. public void paint(Graphics g) {
  13. super.paint(g);
  14. Graphics2D g2 = (Graphics2D)g;
  15. g2.draw(rect);
  16. }
  17.  
  18. public int getXLowerRightCorner() {
  19. return width;
  20. }
  21.  
  22. public int getYLowerRightCorner() {
  23. return height;
  24. }
  25.  
  26. private int xUpperLeftCorner = 0;
  27. private int yUpperLeftCorner = 0;
  28. private int width = 200;
  29. private int height = 100;
  30. private Rectangle rect;
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement