使用GetWidth();?
使用 getWidth()
之后,如何显示面板的宽度?我可以将其放入 jtextfield
/ jtextarea
吗?我不这么认为,但我不确定。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
使用 getWidth()
之后,如何显示面板的宽度?我可以将其放入 jtextfield
/ jtextarea
吗?我不这么认为,但我不确定。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
当然可以在文本组件中显示面板大小。您可以使用
setText(String t)
方法来设置jtextfield 或
jtextarea
。尝试以下操作:它将在JTEXTFIELD中向用户显示面板的宽度。 (或者您可以将文本字段替换为您喜欢的任何文本组件)
您还可以查看 java教程 :如何使用顶级容器 和。 Java教程是Swing Developers的出色官方文件。
It is certainly possible to display the panel size in a text component. You can use
setText(String t)
method to set the display text of aJTextField
or aJTextArea
. Try this:It will display the width of the panel to the user in a JTextField. (Or you can replace the text field to any text components you like)
You can also take a look at these two sections in the Java Tutorial: How to use Top-Level containers and Using Text Components. The Java Tutorial is a great official document for Swing developers.