Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. package Sprite;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import javax.swing.JButton;
  8. import javax.swing.JPanel;
  9.  
  10. /**
  11.  *
  12.  * @author Andrew
  13.  */
  14. public class AreaPanel extends JPanel
  15. {
  16.  
  17.     Graphics playerSprite;
  18.     Color red;
  19.     JButton btn1;
  20.     AreaPanel()
  21.     {
  22.         btn1 = new JButton("GO!");
  23.         this.add(btn1);
  24.        
  25.         btn1.addActionListener((ActionListener)this);
  26.     }
  27.  
  28.     public void paintComponent(Graphics g)
  29.     {
  30.         super.paintComponent(g);
  31.  
  32.         red = new Color(110, 0, 255);
  33.  
  34.         g.setColor(red);
  35.         g.fillRect(5, 5, 50, 70);
  36.     }
  37.  
  38.     public void actionPeformed(ActionEvent e)
  39.     {
  40.         if(e.getSource() == btn1)
  41.         {
  42.             System.out.println("222");
  43.         }
  44.     }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement