Advertisement
Guest User

Untitled

a guest
Jul 28th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. //Somewhere inside of main
  2. while (a == 0) {
  3. if (Panel.getButton() == 10) {
  4. //System.out.println("if it print it works else it doens't");
  5. stuff();
  6. }
  7. }
  8.  
  9. // The class
  10. //private field
  11. int ButtonPress;
  12.  
  13. // button array with event listener
  14. buttons[i].addActionListener(new ActionListener() {
  15. @Override // Just following if possible please explain why this is needed.
  16. public void actionPerformed(ActionEvent e) {
  17. for (int i = 0; i <= 11; i++) // Checking conditions one at a time
  18. if (e.getSource() == buttons[i]) { // if true set button
  19. setButton(i);
  20. }
  21.  
  22. // Method
  23. void setButton(int i) {
  24. this.ButtonPress = i;
  25. }
  26.  
  27. int getButton() {
  28. return ButtonPress;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement