我有一个像这样的屏幕:
+--------+---------------------+
|___A____| |
|________| JComponent I am |
|________| drawing on |
|________| __ __ |
|________| | | |
|________| |
|________| \__________/ |
|________| |
|________| |
|________| |
+--------+---------------------+
而且我想这样做,以便当我单击按钮 A 时,会在我正在绘制的 JComponent 顶部弹出一个托盘?如何最好地实现这一点?通过忽略布局管理器并将其添加到我用作画布或某种分层窗格的 JComponent 中?
+--------+---------------------+
|___A____|_Tray__| |
|________| JComponent I am |
|________| drawing on |
|________| __ __ |
|________| | | |
|________| |
|________| \__________/ |
|________| |
|________| |
|________| |
+--------+---------------------+
为了区分 JPopupMenu 和建议的托盘。
+------+--------------------+
|Button|
+------+
| | <--- JPopupMenu
+------+
+------+--------------------+
|Button|____________| <----- Tray
+------+