java - Dynamically accessing a button when I know the button number -
nine jbuttons
declared :
private javax.swing.jbutton jbutton1; private javax.swing.jbutton jbutton2; private javax.swing.jbutton jbutton3; private javax.swing.jbutton jbutton4; private javax.swing.jbutton jbutton5; private javax.swing.jbutton jbutton6; private javax.swing.jbutton jbutton7; private javax.swing.jbutton jbutton8; private javax.swing.jbutton jbutton9;
i have had button array doesn't suit application.during program run want dynamically access button when know button number.like @ instance want button number 5
, settext("x")
. there way can ? jbutton
array have solved problem doing :
buttonarray[5].settext("x")
but told, overall doesn't suit application.
accessing button number 1 thing. if there other way this,please mention.
create function , write switch statement many number of jbuttons. pass number function , return appropriate nth number of jbutton object. possible way in given circumstances. there no other way in java. there called class.forname create class out of string creates new class of no use you.
Comments
Post a Comment