PDA

View Full Version : Border Layout border issue



hiinsu
12 Jul 2010, 6:40 AM
Hi,

I noticed when I have a content panel(with no border setting) set as one of the border layout region
and collapse it, collapsed header(?) sets borders back on.
is there a way to have no borders at all times?

here's a scenario.
a tab panel contains many tab item.
this tab panel has border and all of nested component has no border
one of the tab item is split into 2 regions : north and center
north is collapsible content panel.
center is another content panel that is not collapsible.

when north panel is collapsed, a new border is created on the left, top, and right.
and overlaps with tab panel borders which makes borders as twice as thick.
how can i get rid of this 2px thick border?

sven
12 Jul 2010, 6:41 AM
When you collapse it it gets replaced with a CollapsedPanel. You need to get that and disable border also on that.

hiinsu
12 Jul 2010, 6:55 AM
thank you! :)

hiinsu
12 Jul 2010, 7:24 AM
BTW, how should I get this collapsed Panel?
I tried adding a collapse event listener to the content panel. (see below) and failed. :s


northPanel.addListener(Events.Collapse, new Listener<ComponentEvent>(){
@Override
public void handleEvent(ComponentEvent be) {
System.out.println("collapse event captured!!");
be.getCompoent().setBorders(false); // get component should return the content panel that is replaced by collapsed panel.
}
});

oxyrox
12 Jul 2010, 7:45 AM
Try to do it like this:


CollapsePanel collapsePanel = new CollapsePanel(contentPanel, new BorderLayoutData(LayoutRegion.NORTH));
collapsePanel.set...

And set your border settings once again on this (I haven't tried this).

Greets,
oxy

hiinsu
12 Jul 2010, 8:00 AM
Oxy,
thnx for your reply.
One question though.
you are creating a new collapse panel rather than grabbing collapse panel created by collapse event.
so, I don't really know how to implement your solution. :s

oxyrox
12 Jul 2010, 8:21 AM
I'm sorry, this previous approach was completely wrong... :(

Try this one:

CollapsePanel collapsePanel = (CollapsePanel) cp.getData("collapse");

Hope I got it this time... ;)

Greets,
oxy

hiinsu
12 Jul 2010, 8:31 AM
Perfect!! Thanks Oxy!!
it worked!!. i didn't know collapse panel should be set as data object to a content panel.
I probably should have looked at the source code
and for anyone who's facing same problem, here is the solution

CollapsePanel collapsePanel = (CollapsePanel) northPanel.getData("collapse");
collapsePanel.setBorders(false);

where northPanel is a content panel or subclass of it.

Don't do:
collapsePanel.setBodyBorder(false); => this will reset body display property and display an empty box
and no need to layout or repaint!