This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem implememnting ActionListener

 
Robert Sheriff
Greenhorn
Posts: 2
Android Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am building a mortgage calculator for my Java class, not I am not trying to get anyone to do my homework, NOT AT ALL, however I have hit a road block and need some fresh eyes. I am trying to implement ActionListener into my code but I continue to get compile errors no matter how I change the configuration and my book has proven NO help for this, so I am turning to the knowledge base available here. As the code stands now, I get a compile error saying that a non-static variable this can not be referenced from a static context, so I tried to move the content with the ActionListener out of the main method with no luck, I created a new public method called contenseFrame() and used the aWindow.add(new contenseFrame()); in my main method but then I get an error saying invalid method declaration; return type required... both errors have me stumped and I feel like I need a fresh set of eyes to look at it...

 
Rob Camick
Ranch Hand
Posts: 2539
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your basic structure is all wrong. Get rid of all the static variables and create the components of your panel in the constructor of your panel. Something like:


Read the Swing tutorial for more examples.
 
Robert Sheriff
Greenhorn
Posts: 2
Android Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I see where I made my mistake... Thank you... I redesigned and it opens, but I get an error when I click Calculate..... Looks like I still need to tweak it

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic