Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Somewhere inside of main
- while (a == 0) {
- if (Panel.getButton() == 10) {
- //System.out.println("if it print it works else it doens't");
- stuff();
- }
- }
- // The class
- //private field
- int ButtonPress;
- // button array with event listener
- buttons[i].addActionListener(new ActionListener() {
- @Override // Just following if possible please explain why this is needed.
- public void actionPerformed(ActionEvent e) {
- for (int i = 0; i <= 11; i++) // Checking conditions one at a time
- if (e.getSource() == buttons[i]) { // if true set button
- setButton(i);
- }
- // Method
- void setButton(int i) {
- this.ButtonPress = i;
- }
- int getButton() {
- return ButtonPress;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement