[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 113 KB, 645x729, 1553202243634.png [View same] [iqdb] [saucenao] [google]
10635759 No.10635759[DELETED]  [Reply] [Original]

what's the cleanest way of hanling an array of buttons in java?
i'm writting a simple game right now, i have already done all the logic, but i really cant get over the game interface
what i need is basically a grid of buttons, just like in chess but the size needs to be dynamic (i.e the user defines the size of the board, doesn't have to be a square)
in the logic im handling the map as an 1d array where i refer to a specific field x,y as map[y*max_x +x] and i've been thinking about doing the same with buttons, but when clicking one, how could i distinguish which button got clicked?

>> No.10635760

>what's the cleanest way of hanling an array of buttons in java?
>i'm writting a simple game right now, i have already done all the logic, but i really cant get over the game interface
>what i need is basically a grid of buttons, just like in chess but the size needs to be dynamic (i.e the user defines the size of the board, doesn't have to be a square)
>in the logic im handling the map as an 1d array where i refer to a specific field x,y as map[y*max_x +x] and i've been thinking about doing the same with buttons, but when clicking one, how could i distinguish which button got clicked?
not science or math

>> No.10635771

>>10635760
computer science

>> No.10635776

>>10635771
>>>/g/