View Full Version : Resize GLAnimCanvas in Java
I would like to know how I can do to resize my GLAnimCanvas in Java. My GLAnimcanvas is inserted in a JPanel which is inserted in a JFrame... I would like to resize the GLAnimCanvas object when I resize my JFrame..
Thanks a lot
You will need to use the ContainerListener interface and resize it yourself on resizeevents. It works just fine eventhough you are mixing light and heavyweight surfaces.
thanks for your reply...
I used a ComponentListener on my JPanel to detect when the window is resized.. but I do not arrive to resize the GLAnimCanvas.. I know what is the new to give to it. I tried to use setSize() and reshape() but nothing changes... Maybe it's not refresh correctly..
Do you know how to proceed..
Thanks a lot
I made a mistake before you need to use the ComponentListener interface, sorry about that. Add the new interface to the jpanel that contains the glanimcanvas. You will have to calculate the correct size yourself, size - insets.
Another problem you might have to look out for is invalidate calls in your swing components. I don't think glanimcanvas will catch them. You might have to override the validate call in the jpanel that contains your glanimcanvas to resize the glanimcanvas manually.
thanks for your help
I arrived to resize the GLAnimCanvas now.. I simply used setSize on the GLAnimCanvas when I detect the panel is resized..and it works..
But if I put an other layout than the FlowLayout it's not always working correctly.. With the flowlayout everything is working correctly..
Now I do not know if the problem could come from the invalidate() method as you said
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.