java - Increment an int using Jbuttons for use with an array -
the program supposed to, every time number button pressed, save number array, counter use point next cell in array seems update when same button pressed twice.
for example if input 121323311 keypad prints 1 1 2 1 2 2 3 3 4 arraycount.
edit: origianal code in buildgui() method was:
jpanel buttons = new jpanel(); buttons.setlayout(new gridlayout(0,3)); jbutton 1 = new jbutton("1"); buttoneventhandler bl1 = new buttoneventhandler(); one.addactionlistener(bl1); jbutton 2 = new jbutton("2"); buttoneventhandler bl2 = new buttoneventhandler(); two.addactionlistener(bl2);
so on each button, i've changed to:
jpanel buttons = new jpanel(); buttoneventhandler bl = new buttoneventhandler(); buttons.setlayout(new gridlayout(0,3)); jbutton 1 = new jbutton("1"); one.addactionlistener(bl); jbutton 2 = new jbutton("2"); two.addactionlistener(bl);
and works. thank you.
it seems have multiple instances of buttoneventhandler
listening individual buttons. purpose, need only one instance of buttoneventhandler
listening to all buttons.