错误:“不推荐使用 Window 类型的 show() 方法”
这是一个简单的程序,只需打开 AWT。我正在使用 eclipse,并且我收到上面显示的frame.show(); 的错误。 Eclipse 正在用一条线跨越“显示”。我想要这个程序做的只是显示一个 300px x 300px 的框架窗口。完整代码如下:
Frame frame = new Frame("Hello World");
// ...
frame.show();
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();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
show()
方法确实已被弃用。 已弃用意味着您不应该再使用它,因为它已被更好的东西取代,并且将来可能会被删除。在这种情况下,您应该使用setVisible(true)
来代替。如果您查看 Javadoc 中是否有已弃用的方法,它通常会告诉您预期的替代方法是什么。
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 usesetVisible(true)
instead.If you go and look at the Javadoc for a deprecated method, it will generally tell you what the intended replacement is.
您现在必须使用 setVisible(true) 来代替。
You now have to use setVisible(true) instead.