• Post Reply Bookmark Topic Watch Topic
  • New Topic

Screen moves on its own

 
Danie Van Eeden
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, sorry for this if it sounds easy & stupid but here goes:
Ive got a Jframe with GRidbaglayout as Layoutmanager. On this frame (on row 1) I have 9 columns which each contain another frame with a graphic.

Ok underneath this (row 2) I have a blank label.
Underneath this (row 3) I have another big panel (also containing gridbaglayout). On this gridbaglayout I have 6 more graphics (3x3).

graphic on top panel further known as G1
graphics on bottom panel further known as G2

What i need to do is click on G1 (top panel) and then replace G2 (bottom panel) with this G1. I do this by firt removing both G1 and G2.

toppanel.remove(g1)
bottompanel.remove(g2)

I then add g1 to the place where g2 was on the bottom panel. Thing is: It doesn't show up until I actually resize the form (even if I just drag it one pixel in any direction).

If I manually resize it in coding: (setsize), then it works, but the whole main frame suddenly jumps about 10% bigger than it was.
I dont want this.
any help would be very greatly appreciated. (if you want my coding, just lemme know, cause I dont know if my expanation is sufficient).
thanks all
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After a series of container.add() or remove() calls, you should call validate() to have to container run its layout manager.
 
Danie Van Eeden
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks will keep that in mind for future use!
 
Ryan Smith
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, try repaint();
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!