Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using two JPanels in one JFrame

I'm attempting to create a program that allows the user to click a button to place something in the JPanel and allowing them to move this item around. I have already found a good layout to use to allow the moving components (see this link). However, I'm just curious the best way to create a layout like this? My hope is to have something like this:

layout idea

How can I accomplish this? Would I want to use two JPanel's or something else?

like image 932
Kynian Avatar asked Oct 24 '12 21:10

Kynian


1 Answers

The main panel (or the window content pane) would have to have a BorderLayout as the layout manager.

Then, the buttons panel would be added to BorderLayout.WEST and the drag panel to BorderLayout.CENTER.

There is a Visual Guide to swing layout managers.

like image 116
Dan D. Avatar answered Sep 21 '22 10:09

Dan D.