Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. package Sprite;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.awt.TextField;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8. import javax.swing.JButton;
  9. import javax.swing.JPanel;
  10.  
  11. class AreaPanel extends JPanel implements ActionListener
  12. {
  13.  
  14.     Graphics playerSprite;
  15.     Color red;
  16.     JButton btn1;
  17.     TextField prnt;
  18.  
  19.     AreaPanel()
  20.     {
  21.         btn1 = new JButton("GO!");
  22.         prnt = new TextField();
  23.         this.add(btn1);
  24.  
  25.         btn1.addActionListener(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.     }
  39.  
  40.     public void actionPeformed(ActionEvent e)
  41.     {
  42.         if (e.getSource() == btn1)
  43.         {
  44.             System.out.println("222");
  45.         }
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement