S
Stéphanie Vanhove
Hello,
I have a JPanel on which I have a square drawing. Now I added this panel to
a gridbaglayout, along with some buttons and a list.
Now the problem is, when I test the program and I drag the window to resize
it, the panel completely disappears as soon as there 's not enough space for
it's preferred size. When I make the window larger again, the panel
reappears.
As it is a project for school, i have to be able to make the window smaller
and still show the panel.
Now, somebody told me to set gbc.fill = GridBagConstraints.BOTH;
And indeed, this worked!
But if I use this, when I enlarge the window, the drawing is not centered
anymore. Even if I use gbc.anchor = GridBagConstraints.CENTER;
This is quite obvious, as the panel is filling the whole area, while the
drawing begins at (0,0) so it seems as if the drawing is always in the upper
left corner.
So I don't really like this solution because of this.
I want to be able to resize the window, without the panel disappearing, but
I also want the drawing in the panel to appear in the center at all times
....
Can anyone please help, because I really don't know anymore!
Thanks already !
I have a JPanel on which I have a square drawing. Now I added this panel to
a gridbaglayout, along with some buttons and a list.
Now the problem is, when I test the program and I drag the window to resize
it, the panel completely disappears as soon as there 's not enough space for
it's preferred size. When I make the window larger again, the panel
reappears.
As it is a project for school, i have to be able to make the window smaller
and still show the panel.
Now, somebody told me to set gbc.fill = GridBagConstraints.BOTH;
And indeed, this worked!
But if I use this, when I enlarge the window, the drawing is not centered
anymore. Even if I use gbc.anchor = GridBagConstraints.CENTER;
This is quite obvious, as the panel is filling the whole area, while the
drawing begins at (0,0) so it seems as if the drawing is always in the upper
left corner.
So I don't really like this solution because of this.
I want to be able to resize the window, without the panel disappearing, but
I also want the drawing in the panel to appear in the center at all times
....
Can anyone please help, because I really don't know anymore!
Thanks already !