Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import java.awt.event.ActionEvent;
  2. import java.awt.event.ActionListener;
  3.  
  4. import javax.swing.ImageIcon;
  5. import javax.swing.JButton;
  6. import javax.swing.JLabel;
  7. import javax.swing.JPanel;
  8.  
  9. public class P3Panel extends JPanel {
  10. JButton button1 = new JButton("PITCH");
  11. Baseball myball = new Baseball();
  12. ImageIcon baseballimage = new ImageIcon("./src/baseball.jpg");
  13. JLabel picture = new JLabel(baseballimage);
  14. JLabel hits = new JLabel("Hits: " + myball.getHitcount());
  15. JLabel fouls = new JLabel("Fouls: " + myball.getFoulcount());
  16. JLabel strikes = new JLabel("Strikes: " + myball.getStrikecount());
  17. public P3Panel(){
  18.  
  19. add(picture);
  20. add(hits);
  21. add(fouls);
  22. add(strikes);
  23. add(button1);
  24.  
  25.  
  26. button1.addActionListener(new CustomActionListener());
  27. }
  28. private class CustomActionListener implements ActionListener
  29. {
  30. @Override
  31.  
  32. public void actionPerformed(ActionEvent arg0)
  33. {
  34. myball.hitcount();
  35.  
  36. }
  37. }
  38.  
  39. {
  40.  
  41. }
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement