Wednesday, March 28, 2012

Re: DockLayoutPanel.getOffsetHeight return zero even after calling forceLayout()

the code is attached as follow:

public class ALS implements EntryPoint {  	ScrollPanel basePanel = new ScrollPanel(); 	DockLayoutPanel baseDockLayoutPanel = new DockLayoutPanel(Unit.PX);	 	SimplePanel simpleContentPanel = new SimplePanel();  	public void onModuleLoad() {			 		RootLayoutPanel rootPanel = RootLayoutPanel.get();		 		rootPanel.add(basePanel); 		basePanel.add(baseDockLayoutPanel); 		baseDockLayoutPanel.setSize("1200", "800");		 		baseDockLayoutPanel.addNorth(CommonPanel.getHeaderPanel(), 20); 		baseDockLayoutPanel.addSouth(CommonPanel.getFooterPanel(), 40);		 		FlowPanel leftSidePanel = CommonPanel.getLeftSidePanel(); 		FlowPanel menuPanel = new FlowPanel(); 		menuPanel.setWidth("150px"); 		menuPanel.addStyleName("menu"); 		menuPanel.add(buildTree());		 		leftSidePanel.add(menuPanel); 		baseDockLayoutPanel.addWest(leftSidePanel, 220);		 		baseDockLayoutPanel.add(simpleContentPanel);		 		baseDockLayoutPanel.setSize("1024", "800");		 		 	}   	Tree buildTree(){ 		Tree treeMenu = new Tree();	 			 		 		final TreeItem searchLogs = new TreeItem("Search Logs");		 		treeMenu.addItem(searchLogs); 		searchLogs.setState(true);		 		 		treeMenu.addSelectionHandler(new SelectionHandler<TreeItem>(){  			@Override 			public void onSelection(SelectionEvent<TreeItem> event) { 				if (event.getSelectedItem().equals(advancedSearchLogs)){ 					//System.out.println(splitLayoutPanel.getWidgetCount()); 					simpleContentPanel.remove(simpleContentPanel.getWidget()); 					simpleContentPanel.add(new AdvancedSearchLogsPanel());					 					advancedSearchLogsPanel.forceLayout(); 					baseDockLayoutPanel.forceLayout();	 					 					int width = advancedSearchLogsPanel.getOffsetWidth() + 220; 					int height = advancedSearchLogsPanel.getOffsetHeight()+ 60; 					// Problem here, getOffSetheight() return zero!! 					// AdvancedSearchLogsPanel is a docklayoutPanel 					baseDockLayoutPanel.setSize(String.valueOf(width), String.valueOf(height)); 				} 			}}); 		return treeMenu; 	} }

On Wednesday, March 28, 2012 4:08:00 PM UTC+8, tong123123 wrote:
there is a simplePanel and the simplePanel add a DockLayoutPanel called AdvancedSearchPanel.
in the AdvancedSearchPanel constructor, the width is set to 100% and height to 1800px.

then there is a menu item and when it is clicked,
I try to add the AdvancedSearchLogsPanel() to simplePanel and then called
advancedSearchLogsPanel.forceLayout()
before calling
advancedSearchLogsPanel.getOffsetWidth() and advancedSearchLogsPanel.getOffsetHeight()
but both return zero!!

what is the problem come from?

On Wednesday, March 28, 2012 4:08:00 PM UTC+8, tong123123 wrote:
there is a simplePanel and the simplePanel add a DockLayoutPanel called AdvancedSearchPanel.
in the AdvancedSearchPanel constructor, the width is set to 100% and height to 1800px.

then there is a menu item and when it is clicked,
I try to add the AdvancedSearchLogsPanel() to simplePanel and then called
advancedSearchLogsPanel.forceLayout()
before calling
advancedSearchLogsPanel.getOffsetWidth() and advancedSearchLogsPanel.getOffsetHeight()
but both return zero!!

what is the problem come from?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/bqOoq1ki_0AJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment