aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Screen moves on its own Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Screen moves on its own" Watch "Screen moves on its own" New topic
Author

Screen moves on its own

Danie Van Eeden
Greenhorn

Joined: Sep 03, 2003
Posts: 13
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


Regards<br />-dve83-
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
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

Joined: Sep 03, 2003
Posts: 13
thanks will keep that in mind for future use!
Ryan Smith
Ranch Hand

Joined: Jun 29, 2004
Posts: 40
Also, try repaint();
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Screen moves on its own
 
Similar Threads
Help sorting out what combination of layouts will provide the result I need
how to print entire Jframe ?
Sprites disappearing after scaling down window? Aaargh the frustration!
Canvas HELP!!!
Problems positioning buttons in GridBagLayout