java - Combine output of two different buttons -


i writing code vending machine , have button layout of letters , numbers.

right now, if press "a" button, prints "a" box, if press "1" button, replace "a" that's in box , print "1" in place. how can make output "a1" instead of 1 or other?

 string buttontext = "";         for(int = 0; < 12; i++) {             if(event.getsource() == button[i]) {                      jbutton clickedbutton = (jbutton) event.getsource();                     string buttontext1 = clickedbutton.gettext();                     buttontext += buttontext1;                     itemselection.settext(buttontext); 

at time won't able click more 1 button. instead of code:

string buttontext = "";         for(int = 0; < 12; i++) {             if(event.getsource() == button[i]) {                      jbutton clickedbutton = (jbutton) event.getsource();                     string buttontext1 = clickedbutton.gettext();                     buttontext += buttontext1;                     itemselection.settext(buttontext); 

try this:

string buttontext = ((jbutton) event.getsource()).gettext(); itemselection.settext(itemselection.gettext() + buttontext); 

edited:

in order limit input, try documentfilter.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -