Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Sprite;
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.JButton;
- import javax.swing.JPanel;
- /**
- *
- * @author Andrew
- */
- public class AreaPanel extends JPanel
- {
- Graphics playerSprite;
- Color red;
- JButton btn1;
- AreaPanel()
- {
- btn1 = new JButton("GO!");
- this.add(btn1);
- btn1.addActionListener((ActionListener)this);
- }
- public void paintComponent(Graphics g)
- {
- super.paintComponent(g);
- red = new Color(110, 0, 255);
- g.setColor(red);
- g.fillRect(5, 5, 50, 70);
- }
- public void actionPeformed(ActionEvent e)
- {
- if(e.getSource() == btn1)
- {
- System.out.println("222");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement