Re: Accessing static method
Hmm, I can't seem to spot the difference between any of the code you posted :P
Is your JFrame frame; declared outside of the main method?
Re: Accessing static method
Code :
frame.setDefaultLookAndFeelDecorated(true);
The above code is accessing a static method from an defined instance. It will still compile, but you will receive a warning. You should listen to your compiler, access static methods the correct way...by using the class name followed by the static variable/method.
Code :
JFrame.setDefaultLookAndFeelDecorated(true);
Re: Accessing static method
Bear in mind that we're talking about defaults, so it is ok to set these for frames in general (until you say otherwise).
If you check the reference, indeed setDefaultLookAndFeelDecorated() is static and setDefaultCloseOperation() isn't. Not sure why, but it is the case:
Java Platform SE 6
Your import javax.swing.JFrame; has to be what allows you to leave off the JFrame part. It wasn't completely clear to me that that always works when you have the import statement, but I'd say that's gotta be the reason why NetBeans doesn't complain.
Re: Accessing static method
Quote:
Originally Posted by
aisthesis
Your import javax.swing.JFrame; has to be what allows you to leave off the JFrame part. It wasn't completely clear to me that that always works when you have the import statement, but I'd say that's gotta be the reason why NetBeans doesn't complain.
This is not true. Would have to see all of his code to know the reason. I would guess that the object that contains the method, that contains that code, is extending JFrame (or extending something that is extending JFrame).