|
-
September 24th, 2011, 10:17 AM
#10
Re: Help with ActionListener?
Putting virtually all your code in your main method and having all your variables as static goes against all OO programming techniques and is the root cause of all your problems.
Also your code appears to be trying to use different approaches to adding an ActionListener. You need to choose just one approach. The easiest way to get your actionListener working is to do the following:
- Delete the actionPerformed method in the CalcReview class.
- Remove the local declarations of jLabel3, jLabel3, jTextField1 in the main method
- Create a CalcReview constructor and move all the code in the main method into it.
- Add the line new CalcReview(); to the now empty main method
- Remove the AnswerBox.addActionListener(this); line from the actionPerformed method in the keyEvents class.
- Remove the implements ActionListener from the CalcReview class declaration.
- Add the AnswerBox.addActionListener(this); line to the line after the line which assigns a JTextField to AnswerBox.
- Remove static from all your class variables
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|