JButtons behavior in ActionListener[solved]
Hi
I have a problem with a program i am writing.
Not the problem:I have jButtons in a JPanel and depending which of 3 JCheckbox's is checked, the number of buttons changes. I have them in a Buttongroup. I have also programmed a JMenu that autochecks the checkboxes through an ActionListener and the number of boxes relative to the selected checkbox works fine thanks to the ItemListener.
The real Problem:I need the buttons to behave differently depending on how many there are in the panel.
Ex: button 4 subtracts 2 if 4 buttons are present but subtracts 1 if 9 buttons are present. Is there a way to code this? and if so...how? If given 1 example, I can probably figure the rest out. Any help you can give me would be greatly appreciated.
Re: JButtons behavior in ActionListener
The Container class has a methods you can call to get information about the components it contains.
Re: JButtons behavior in ActionListener
If your buttons are in a ButtonGroup, you can call the getButtonCount() method (ButtonGroup (Java Platform SE 6))
Re: JButtons behavior in ActionListener
Thats helps dramatically....It gives me a direction to follow