如何实现出现在控件上的托盘?
我有一个像这样的屏幕:
+--------+---------------------+
|___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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论