Tutorial :java border gui



Question:

I am not good with GUIs or User Interfaces in Java.

Would a Border or JPanel be good for something like the image below?

enter image description here

So, what would be the best option for me? Thank you.


Solution:1

Read the section from the Swing tutorial on Using Layout Managers. You can easily nest panels to get the desired effect.

Maybe start with a BorderLayout. Then you can add a panel that uses a GridLayout, which contains all your image tiles, to the CENTER of the BorderLayout. Then you can add the scrollpane containing the text area to the SOUTH. Then you can create another panel to add to the EAST.

Be creative and experiment.


Solution:2

You can make 4 seperate panels for a border, using BorderLayout.NORTH,BorderLayout.EAST,BorderLayout.SOUTH,and BorderLayout.WEST, This is the easiest way in my opinion.

By the way, in the top right of your picture, where you wanted the information panel, you should put an information LABEL (JLabel) instead, because they hold text. JLabel topRight = new JLabel(); then set the text, position, etc.

p.s. to erase the borders around every tile (if you want to do so), use setBorderPainted(false).


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »