错误:“不赞成使用Window类型的show()方法”; [英] Error: "The method show() from the type Window is deprecated"

查看:124
本文介绍了错误:“不赞成使用Window类型的show()方法”;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个仅打开AWT的简单程序。我正在使用eclipse,我得到了上面显示的frame.show()错误。 Eclipse正在用一行横越显示。我想要这个程序要做的只是显示一个300px x 300px的框架窗口。完整代码如下:

this is a simple program to just open an AWT. Im using eclipse and i get the error shown above for frame.show(); Eclipse is crossing "show" with a line. All i want this program to do is just display a 300px by 300px frame window. Heres the full code:

    Frame frame = new Frame("Hello World");
    // ...        
    frame.show(); 


推荐答案

方法 show() 确实已被弃用。 已弃用意味着您不再需要使用它,因为它已经被更好的东西所取代,并且将来可能会被删除。在这种情况下,应该使用 setVisible(true)

The method show() is, indeed, deprecated. Deprecated means that you're not supposed to use it anymore, as it's been replaced by something better and may be removed in the future. In this case, you're supposed to use setVisible(true) instead.

如果您去看看Javadoc中已弃用的方法,它通常会告诉您预期的替代方法是什么。

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

这篇关于错误:“不赞成使用Window类型的show()方法”;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆