如何在Java中获得面板的大小?
我尝试使用panel.getSize()
,但它说java.awt.dimension [width = 0,高度= 0]
我尝试了panel.getheight ()
,但它说是0
I tried to get with the panel.getSize()
but it said java.awt.Dimension[width=0,height=0]
I tried panel.getHeight()
but it said it is 0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您获得0x0尺寸的原因是:
我这样做的:
要解决此问题,请确保在获取大小的信息之前先渲染所有对象
:您的选择,我的实例是Mouselistener):
用于示例:
The Reason why your getting 0x0 as dimension is:
I assume you Did This:
To Fix this, Just Make Sure to Render All Objects First before getting the Info for size:
Bonus(in order to get info infinitely by using Listener of your choice, My Instance is MouseListener):
for sample: