• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem implememnting ActionListener

 
Greenhorn
Posts: 2
Android Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...

 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
reply
    Bookmark Topic Watch Topic
  • New Topic