Reputation: 1
I'm quite new to Java and programming, but I'm trying to learn by doing. To avoid too much hassle early-on I've used the NetBeans GUI builder to make a basic form with buttons and labels etc.
My problem is that when I call some methods inside the auto-generated Action Listener for a button, I get an error telling me how I cannot call a non-static method ( the dispose() method ) from a static context. While I understand the distinction between static and non-static in theory, I find myself lost when I'm sitting at the keyboard. I feel like I'm missing something important.
I need help getting un-stuck on this particular problem before I can move forward.
Thanks
Upvotes: 0
Views: 823
Reputation: 36423
well you cant just call dispose()
as this is an instance method, you need to call dispose on the instance of your JFrame
or JDialog
or what-ever-window like this:
frame1.dispose():
Upvotes: 1