Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- class ReactionPanel extends JPanel {
- int size;
- Color color;
- public void paintComponent(Graphics g) {
- super.paintComponent(g);
- g.setColor(color); /* initial color wont matter */
- int centerY = super.getHeight()/2;
- int centerX = super.getWidth()/2;
- g.fillOval(centerX, centerY, size, size); /* initial size 0, so initiallly nothin display until you call setSmallCircle or setBigCircle */
- }
- public void setSmallCircle(Color c) {
- this.color = c;
- size = 10;
- repaint();
- }
- public void setBigCircle(Color c) {
- this.color = c;
- size = 50;
- repaint();
- }
- }
Add Comment
Please, Sign In to add comment