1

I am currently coding on a swing layout. Here is what it looks like right now:

enter image description here

And this is what it should look like:

enter image description here

right now the Button is on the wrong Place:

Here is my code:

    layout.setHorizontalGroup(
            layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(header)//table header
                    .addComponent(tableG)//here comes the table
                    .addGroup(layout.createParallelGroup()
                            .addComponent(b3)//button1
                            .addComponent(b4)))//button2
            );
    layout.setVerticalGroup(
            layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(b3)//button1
                    .addComponent(b4))   //button2
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(header)//tableheader


.addComponent(tableG))//table
                );

        layout.linkSize(SwingConstants.HORIZONTAL, b3, b4);

Why is my Button over my table?

I appreaciate your answers!!!

maximus
  • 11,264
  • 30
  • 93
  • 124
  • 1
    One piece of advise: ditch the `GroupLayout` and use another `LayoutManager`. `GroupLayout` is, as described in the documentation, not suited for hand-coding a layout and more developed to be used in combination with a GUI builder – Robin Oct 04 '12 at 09:00
  • Stop wasting your time, use [WindowBuilder](https://developers.google.com/java-dev-tools/wbpro/quick_start) – Kai Oct 04 '12 at 09:06
  • which Layout would you recommend, cause I want to learn the GUI creation first and then switch to a GUI Builder... – maximus Oct 04 '12 at 09:16
  • 3
    For that I would use a `BorderLayout` with table in center, and a `FlowLayout` or `BoxLayout` panel with the buttons in the south – Robin Oct 04 '12 at 10:25
  • 1
    There's a related example [here](http://stackoverflow.com/a/7519403/230513). – trashgod Oct 04 '12 at 15:48

0 Answers0