如何实现出现在控件上的托盘?

发布于 2024-11-03 00:49:48 字数 1193 浏览 1 评论 0原文

我有一个像这样的屏幕:

+--------+---------------------+
|___A____|                     |
|________| JComponent I am     |
|________|  drawing on         |
|________|    __        __     |
|________|     |        |      |
|________|                     |
|________|    \__________/     |
|________|                     |
|________|                     |
|________|                     |
+--------+---------------------+

我想这样做,以便当我单击按钮 A 时,我正在绘制的 JComponent 顶部会弹出一个托盘?如何最好地实施这一点?通过忽略布局管理器并将其添加到我用作画布或某种分层窗格的 JComponent 中?

+--------+---------------------+
|___A____|_Tray__|             |
|________| JComponent I am     |
|________|  drawing on         |
|________|    __        __     |
|________|     |        |      |
|________|                     |
|________|    \__________/     |
|________|                     |
|________|                     |
|________|                     |
+--------+---------------------+

为了区分 JPopupMenu 和建议的托盘。

+------+--------------------+
|Button|
+------+
|      |  <--- JPopupMenu
+------+

+------+--------------------+
|Button|____________|  <----- Tray
+------+

I have a screen like so:

+--------+---------------------+
|___A____|                     |
|________| JComponent I am     |
|________|  drawing on         |
|________|    __        __     |
|________|     |        |      |
|________|                     |
|________|    \__________/     |
|________|                     |
|________|                     |
|________|                     |
+--------+---------------------+

And I would like to make it so that when I click the button A a tray is popped up over top of the JComponent I am drawing on? How best to implement this? Through ignoring the layout manager and adding it to my JComponent that I'm using as a canvas or some kind of layered pane?

+--------+---------------------+
|___A____|_Tray__|             |
|________| JComponent I am     |
|________|  drawing on         |
|________|    __        __     |
|________|     |        |      |
|________|                     |
|________|    \__________/     |
|________|                     |
|________|                     |
|________|                     |
+--------+---------------------+

To manke the distinction between JPopupMenu and the proposed tray.

+------+--------------------+
|Button|
+------+
|      |  <--- JPopupMenu
+------+

+------+--------------------+
|Button|____________|  <----- Tray
+------+

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文