玻璃板与分层玻璃的用例

发布于 2024-08-27 13:14:54 字数 77 浏览 10 评论 0原文

我一直对玻璃板和分层玻璃之间的区别有点模糊。玻璃板本质上只是“根玻璃的最顶层”,还是它的行为有所不同?什么时候会使用分层窗格而不是玻璃窗格?

I've always been a little fuzzy on the difference between the glass pane and a layered pane. Is the glass pane essentially just "the very top layer of the root pane," or does it behave differently? When would you use a layered pane instead of the glass pane?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零度° 2024-09-03 13:14:54

它们是两个不同的东西:

  • 分层窗格是在 JFrame 中添加或显示的所有内容的目标。例如,每个普通组件如 JLabelsJTextFieldsJTable 等。此外,它还隐式处理添加到的元素的 z 顺序它可以处理弹出菜单或拖放效果:这是因为弹出菜单被添加到分层窗格中,其 az 高于普通组件,最终效果保持在其他内容之上。请参阅此处以更好地了解该行为。< /p>

  • 玻璃窗格是一个可选层,默认情况下是隐藏的,并且在任何情况下都保留在图层窗格的顶部。因此,基本上您在玻璃板上绘制的所有内容都将始终可见:您可以将其视为应用在普通 JFrame 顶部的透明纸,您可以根据需要选择使用它.

分层窗格玻璃窗格都放置在根窗格上,根窗格是构建每个框架的基础。

They are two different things:

  • the layered pane is the destination of all the contents that are added or shown inside a JFrame. For example, every normal component like JLabels, JTextFields, JTable etc.. in addition it implictly handles z-ordering of elements that are added to it so it can handles popup menus, or drag and drop effects: this because a popup menu is added to the layered pane with a z higher than the normal components, with the final effect to stay on top of other things. See here to understand the behaviour better.

  • the glass pane is an optional layer that is hidden by default and stays in any case on top of the layer pane. So basically everything you draw onto the glass pane will be always visible: you can think of it as a trasparent sheet that is applied on the top of a normal JFrame that you can choose to use you need special effects.

Both the layered pane and the glass pane are placed on the root pane that is the basis from which every frame is built up.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文