Error: "The show () method of type Window is deprecated"

This is a simple program to simply open AWT. Im using eclipse and I get the error shown above for frame.show (); Eclipse crosses the "show" with a line. All I want this program to execute is just a window with a resolution of 300 pixels by 300 pixels. Here is the complete code:

Frame frame = new Frame("Hello World"); // ... frame.show(); 
+8
java deprecated
source share
2 answers

The show() method is indeed deprecated. Obsolete means that you should no longer use it, since it is replaced by something better and may be removed in the future. In this case, you should use setVisible(true) instead.

If you go over and look at Javadoc for the deprecated method, it will usually tell you what the intended replacement is.

+18
source share

Now you need to use setVisible(true) .

+1
source share

All Articles