• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can I access multiple ToggleButtons created in a class?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a GridPane (6x9) made with SceneBuilder. Inside that GridPane I created 50 ToggleButtons in my controller with the following code:



In my MainApp.java I've created an array of integers:



I have two questions.

1. I want is to update the selectedNumbers array with the numbers of the ToggleButtons that are pressed. For example, if I press button 1, 13 and 25, the array should be [1, 13, 25]. When I "turn off" a button, that number should be removed from the array. How can I add and remove those values? Where should I have this code? Inside the initialize method?

2. I have a method that randomly picks N numbers from the 50 available (1 to 50). When the user clicks a button, I want the ToggleButtons with that number to be "turned on". I know how to do a loop but how can I access the buttons? I mean, I named them tb_1, tb_2 and so on. So... how can I call them?

Thanks!
 
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question is answered at:

http://stackoverflow.com/questions/28541310/how-can-i-access-multiple-togglebuttons-created-in-a-class
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pedro, please BeForthrightWhenCrossPostingToOtherSites
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic