Everything appears to be in place and with no errors while open in Eclipse. When I run the program though, it will only let me select ONE of the options on the checkbox buttons, and also the calculate and exit buttons are not working. Where exactly have I gone wrong with this? My instructor mentioned something about making the calculate/exit buttons NOT static, but if I do that, it won't even run and errors pop up everywhere, so I'm pretty confused. The following is the last point where I had no errors, yet had the button issue. All of my other attempts at trying different fixes kind of broke everything, so this is the functional version.
Jesper de Jong wrote:Your CalcButtonListener and ExitButtonListener are ItemListeners. Make these ActionListeners instead, if you want to do something when the buttons are clicked.
In lines 235 and 236, use addActionListener instead of addItemListener to add the listeners to the buttons.
I changed those and it's still performing no action when I try to click them.
Joined: Oct 13, 2005
Also I have removed some of the blank space from your code; too much blank space makes it difficult to read. Don’t use tabs. Have a look at our suggestions about indentation.
Joined: Jun 09, 2003
you create your buttons in buildButtonPanel
calcButton = new JButton("Calculate");
exitButton = new JButton("Exit");
and add (now) actionListeners to them.
but then in the constructor of autoMaintenanceSvcCalc() you re-create the buttons
serviceCalculatorGUI.calcButton = new JButton("Calculate");
serviceCalculatorGUI.exitButton = new JButton("Exit");
these buttons do not have a listener added to them
comment out the lines
//serviceCalculatorGUI.calcButton = new JButton("Calculate");
//serviceCalculatorGUI.exitButton = new JButton("Exit");
and in the constructor of serviceCalculatorGUI() move
mainPanel = new autoMaintenanceSvcCalc();