How do I go about implementing a tray that appears on controls?
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
+------+
精彩评论