Which layout and containers are suitable for creating a graphical interface such as Tiled?

I was going to use the Tiled program, but decided not to, as it did everything in blocks and limited a bit of freedom.

My question is which layout manager would you use to look like Tiled. I really like the feeling, and when I make this tool, I want it to work the same way when I move components around.

Here is what I did and thought:

  • Have a JFrame that contains the menu bar and content area. (Works fine atm)
  • The content area is BorderLayout. (Works fine atm)
  • Inside the content pane is a toolbar as shown below. (Works fine atm)
  • Inside the toolbar, I will see buttons that will be displayed as images, like an icon, and you can click the same way as the red circle
  • Content panel will contain two J panels
  • The first panel J will look like a black circle and will contain a map, which I will draw there.
  • The second J panel will contain components such as layers, history, atlases, and images.
  • The first panel J will be the Center, and the second panel J will be East

Here are my problems:

  • When I run the GUI, I almost don't see a suitable JPanel and it seems like I cannot expand it if I don't have the actual content in it, like a JList or something like that.

I ask you all to guide me about what you will do. Although I made a graphical interface before I am not experienced enough to know how to really deal with this when it comes to choosing a layout manager and how to use it in this particular situation. All I need is basic information on how you do it and why , no code is needed. THANKS!

Tiled

My program like tiled

+4
source share
2 answers

I recommend using MigLayout . This is a very powerful and very well supported third-party layout manager. There were (still unsuccessful) petitions to include it in Java. MigLayout will allow you to do anything you want without any compromises and the use of much less code. I could continue, but if you just look through your demos and sample code, you will see for yourself.

+4
source

Let your right-hand JPanel be a subclass of JPanel and override its getPreferredSize () method, returning the appropriate size that most (but not all) layout managers will adhere to.

+3
source

All Articles