my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Problem implememnting ActionListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem implememnting ActionListener" Watch "Problem implememnting ActionListener" New topic
Author

Problem implememnting ActionListener

Robert Sheriff
Greenhorn

Joined: May 08, 2011
Posts: 2

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

Joined: Jun 13, 2009
Posts: 2153
    
    7
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

Joined: May 08, 2011
Posts: 2

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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem implememnting ActionListener
 
Similar Threads
last week of class last assignment. Any help is appreciated.
Calculate button action code
Help with errors again
GUI Mortgage Calculator
One error in code..not understanding what it tells me. Code works it is on line 55.