PDA

View Full Version : ContentPanel expand() Problem



haydar
21 Jan 2010, 1:35 AM
Hi,

I have two ContentPanels: centerPanel and eastPanel.
There is a tree in centerPanel and there is a text in eastPanel.
When I click a leaf, I want eastPanel to expand as I set the text sth up to the clicked node.
When I click a node which is not a leaf, I want eastPanel to collapse.

When I run the program, eastPanel comes collapsed as I wanted and expands when I click a leaf. It also collapses when I click a non-leaf node. Up to now everything is fine.

But after collapsing, when I click a leaf again (second time), it does not expand. I expand it manually and I click a non-leaf and it collapses. So I thought that there might be a problem with expand(). Because when I debugged I saw that eastPanels state changes when I click the nodes.

Please help me with this subject it is very very urgent. I am sending the code piece:


myTree.addListener(Events.OnClick, new Listener<TreeEvent>()
{
public void handleEvent(TreeEvent be) {
detail.setText(myTree.getSelectionModel().getSelectedItem().getText());
if(myTree.getSelectionModel().getSelectedItem().isLeaf())
{
if(eastPanel.isCollapsed())
{
eastPanel.expand();
eastPanel.layout();
}
}
else
{
eastPanel.collapse();
eastPanel.layout();
}
}
});

haydar
21 Jan 2010, 2:21 AM
Ok, I found the problem.

ContentPanels were in a borderlayout and this was causing it.

I wrote borderLayout.expand(LayoutRegion.EAST); instead of eastPanel.expand() and it worked...