Positioning Content in a GInternalFrame

1 view
Skip to first unread message

Mike Olson

unread,
Aug 4, 2008, 11:17:42 PM8/4/08
to Gwt Window Manager

I'm putting a ScrollPanel inside a resizable GInternalFrame.

When I resize the Frame larger then the size of the widgets contained
in the ScrollPanel, the panel centers itself in the frame (both
vertically and horizontally).

In .5.x, where I first started playing with GWM, there used to be the
methods "setContentHorizontalAlignment" and
"setContentVerticalAlignment" which fixed this for me, but they seem
to have disappeared.

I've tried just about every combination of CSS trickery I can think
of, but cannot anchor the scroll panel to the upper left hand corner
of the Frame.

Am I missing something?

Luciano Broussal

unread,
Aug 5, 2008, 3:47:45 AM8/5/08
to gwt-windo...@googlegroups.com
Hi,

setSize("100%" , "100%") should fix the issue ...

HTH

Luciano

Mike Olson

unread,
Aug 5, 2008, 1:49:12 PM8/5/08
to Gwt Window Manager

Hi Luciano,

Did you mean to call setSize("100%","100%") on the Frame? When I
try that I get a really big initial frame, the content is in the
middle of the frame and it is very jerky on a resize.

I have the size of the scroll panel set to 100% and 100% already.

Mike


On Aug 5, 1:47 am, "Luciano Broussal" <luciano.brous...@gmail.com>
wrote:
> Hi,
>
> setSize("100%" , "100%") should fix the issue ...
>
> HTH
>
> Luciano
>

Luciano Broussal

unread,
Aug 5, 2008, 3:26:40 PM8/5/08
to gwt-windo...@googlegroups.com
Hi Mike,

No on the scrollpane but seems you did try that without success.

I'm very sorry to hear that but i'm under the work for now. I can't test it right now.

Regards

Luciano

Nate.G

unread,
Aug 14, 2008, 12:15:22 PM8/14/08
to Gwt Window Manager
I had this same issue but was able to fix it by accessing the
FlexTable that holds the content inside the GFrame. A FlexTable then
has methods that accesses its cellFormatter which can then be used to
set its alignment. The problem is that the centerRow FlexTable that
holds the content of the window in GFrame is a protected variable. To
get around this I had to extend the GFrame class and create a new
method that would return the Flextable. Like this...


public FlexTable getInternalTable()
{
return centerRow;
}


Now once you have called the getInternalTable() method on ur extended
GFrame class and get the centerRow Flextable, you can now change the
GFrame content's alignment...


myExtendedGFrame myFrame = new myExtendedGFrame();

myFrame.getInternalTable().getCellFormatter().setVerticalAlignment(0,
1, HasVerticalAlignment.ALIGN_TOP);
myFrame.getInternalTable().getCellFormatter().setHorizontalAlignment(0,
1, HasHorizontalAlignment.ALIGN_LEFT);


Notice I'm accessing the cell at (0,1) of the FlexTable as that is the
cell with the content of the GFrame. I've only started using GWM since
ver 0.6.6 so I don't know about methods like
setContentHorizontalAlignment existing before that. It does seem odd
that they would disappear. Anyways this trick should get you around
the issue. Maybe Luciano could fill us in on why they were taken out
of the newer releases :)

Good luck,

Nate


On Aug 5, 12:26 pm, "Luciano Broussal" <luciano.brous...@gmail.com>
wrote:
> > > > Am I missing something?- Hide quoted text -
>
> - Show quoted text -

Luciano Broussal

unread,
Aug 15, 2008, 3:10:39 AM8/15/08
to gwt-windo...@googlegroups.com
Nate,

thank you very much for that contribution.
My thought are :

A GWM frame must be view like a agnostic and generic container for widgets and it doesn't have the responsibility to layout them in a specific maner insite it.

Maybe a gwm frame should have is content AREA set with size (100%, 100%) but in any case you should be able to play with the alignement inside the content area.

In the case of Mike and your you should include into the content area your personal container let's say for example a verticalpanel , sized(100%,100%) and now you can do whatever layout and alignment into it.
so if you resize the frame the your layout should follow your directive but not tell to the frame how to display the widgets that i think it is a specific to each frame created by users.

What i want to say it's to had into the content area your  global layout panel. I think it's that way it's work with Swing which is the underlying light model of gwm ...

Now if you had your let's say global layout container  Vertical panel sized 100% 100% and if you resize the frame and the panel not grow it's a gwm frame bug, i would say ;)

Not sure i explained well.

Tell me what do you think guys.

Anyway many thanks fro your interest.

Luciano

Nate.G

unread,
Aug 15, 2008, 1:31:10 PM8/15/08
to Gwt Window Manager

Thanks Luciano for your explaination.

I completely agree with your belief that GWM Frames should stay as
generic as possible, and your right that using a VerticalPanel does
fix the alignment problem. Since the ScrollPanel doesn't implement the
HasHorizontalAlignment and HasVeticalAlignment interfaces I would
suggest to Mike to just wrap the ScrollPanel in a VerticalPanel and
set the VerticalPanel's alignment. I tested it and it works. Something
like this...

------------

longListOfStuff= new VerticalPanel();

scroller = new ScrollPanel(longListOfStuff);
scroller.setSize("100%", "100%");

globalContainer = new VerticalPanel();
globalContainer.add(scroller);
globalContainer.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
globalContainer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
globalContainer.setSize("100%", "100%");

myGFrame.setContent(globalContainer);

------------

Hopefully, this solves your problem Mike as it is 100X more elegant.

Nate




On Aug 15, 12:10 am, "Luciano Broussal" <luciano.brous...@gmail.com>
wrote:
> > > - Show quoted text -- Hide quoted text -

Luciano Broussal

unread,
Aug 15, 2008, 3:04:52 PM8/15/08
to gwt-windo...@googlegroups.com
You 100% got what i thought Nate!
thanks for the snippet!

Luciano

On Fri, Aug 15, 2008 at 7:31 PM, Nate.G <Nate.Ge...@gmail.com> wrote:


Thanks Luciano for your explaination.

I completely agree with your belief that GWM Frames should stay as
generic as possible, and your right that using a VerticalPanel does
fix the alignment problem. Since the ScrollPanel doesn't implement theou git

Mike Olson

unread,
Aug 28, 2008, 12:21:25 PM8/28/08
to Gwt Window Manager


Thanks for all of the responses guys. I stumbled across Nate's
solution the other day, but will switch to wrapping my SP in a VP.

Mike



On Aug 15, 1:04 pm, "Luciano Broussal" <luciano.brous...@gmail.com>
wrote:
> You 100% got what i thought Nate!
> thanks for the snippet!
>
> Luciano
>
Reply all
Reply to author
Forward
0 new messages