如何实施控件上显示的托盘?

时间:2011-04-21 14:51:26

标签: java swing layout-manager jcomponent jlayeredpane

我有一个这样的屏幕:

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

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

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

要掌握JPopupMenu与拟议托盘之间的区别。

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

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

0 个答案:

没有答案