Guest User

Untitled

a guest
Jan 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4.  
  5. class ReactionPanel extends JPanel {
  6. int size;
  7. Color color;
  8.  
  9. public void paintComponent(Graphics g) {
  10. super.paintComponent(g);
  11. g.setColor(color); /* initial color wont matter */
  12. int centerY = super.getHeight()/2;
  13. int centerX = super.getWidth()/2;
  14. g.fillOval(centerX, centerY, size, size); /* initial size 0, so initiallly nothin display until you call setSmallCircle or setBigCircle */
  15. }
  16.  
  17. public void setSmallCircle(Color c) {
  18. this.color = c;
  19. size = 10;
  20. repaint();
  21. }
  22.  
  23. public void setBigCircle(Color c) {
  24. this.color = c;
  25. size = 50;
  26. repaint();
  27. }
  28. }
Add Comment
Please, Sign In to add comment