5

I know this is a simple procedure with JInternalFrame, but can it be done with a measly JPanel?

farm ostrich
  • 5,881
  • 14
  • 55
  • 81
  • Can you clarify a bit on just what it is you're trying to achieve? Why are you trying to place a JPanel directly in a JDesktopPane? Will this JDesktopPane hold other JInternalFrames and are they supposed to be under the JDesktopPane? Have you considered using a JLayeredPane to hold the JDesktopPane and then adding your JPanel to the layered pane (or using the glass pane)? – Hovercraft Full Of Eels Aug 16 '11 at 14:46
  • Sure, I have a JDesktopPane with several JinternalFrames that the client can interact with. In the corner of the desktop is a JPanel that acts as a toolbar (has some icons). Naturally this toolbar should always be on top. Need I convert it to an internal frame? – farm ostrich Aug 16 '11 at 14:48

2 Answers2

6

If the tool bar is sitting across one of the sides of the GUI, why try to add the toolbar directly to the JDesktopPane? Why not hold everything in a JPanel that uses BorderLayout, add the JDesktopPane to this JPanel BorderLayout.CENTER and add the toolbar to the JPanel BorderLayout.WHATEVER (depending on where you want to place it)?

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
4

Instead of JPanel for your toolbar, consider JToolBar in conjunction with Action. Conveniently, a JToolBar is detachable on most platforms. There are related examples here and here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045