2

I have a problem with GridBagLayout. My components doesnt want to look like i want ;) I want to make a layout like this:

enter image description here

I wrote a code:

    JTextField first = new JTextField();
    ...
    add(third, c);

Results look like this, which is "almost" good ;]

enter image description here

Do you know maybe, how to customize it?

Thanks in advance, Marcin

// Edit

Hey, i solved a problem with MigLayout (thanks to mKorbel). Code looks like this (to remove tracking lines, remove debug from constructor):

setLayout(new MigLayout("debug"));
add(new JPanel(), "height 200:75%:10000, width 200:75%:10000");
add(new JPanel(), "height 200:75%:10000, width 50:25%:10000, wrap");
add(new JPanel(), "height 50:25%:10000, width 100%, span");

(ps if u dont want to make upper bound (10000), you can write hmin x, hmax y ... I dont need it ;) )

marxin
  • 3,692
  • 3
  • 31
  • 44

1 Answers1

3

This Image talking about BorderLayout, you have to read BorderLayout tutorial, then maybe there no reason thinking and implementing GridBagLayout

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • Good choice; a nested `Box Layout` works well for components in the upper, right pane. – trashgod Mar 14 '12 at 01:47
  • Thanks, i will take a look. But its possible to set percentage size there? Or row/col span? – marxin Mar 14 '12 at 11:58
  • 1
    no directly isn't possible, then you have look back to GridBagLayout or use todays MigLaoyut, this [code could be help you with GridBagLayout](http://stackoverflow.com/a/9668020/714968) – mKorbel Mar 14 '12 at 12:02