如何在Java Swing中使用Label实现视图?
假设后面使用的是JTextPane,我想实现一个带有标签的视图。但是如何在 Java 中实现视图呢?这与 Java Swing 上 iPhone 上的 UIView 类似吗?谢谢。
Assume that the back is using a JTextPane, and I would like to implement a view with a label. But how can I implement the view in Java? is that something like UIView on iPhone on the Java Swing? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这没什么特别的;只需在窗口底部打包一个额外的
JPanel
,然后在其中放入一个JLabel
即可;根据需要设置JLabel
的文本。There's nothing special about this; just pack an extra
JPanel
along the bottom of your window, and put aJLabel
into it; set the text of theJLabel
as needed.如果我理解正确的话,您希望在
JTextPane
顶部显示一个JLabel
。如果是这样,请使用JLayeredPane
。阅读有关分层窗格的 Swing 教程,了解如何使用它们。
If I understand correctly, you would like to display a
JLabel
on top of aJTextPane
. If so, use aJLayeredPane
.Read the Swing tutorial on layered panes to learn how to use them.
您在寻找这样的东西吗?
请参阅 闪烁
Are you looking for something like this?
See Twinkle