做到這一點的最好方法是使用CSS selectors併爲SplitLayoutPanels添加樣式名稱。
SplitLayoutPanel greenPanel = new SplitLayoutPanel();
greenPanel.addStyleName("green");
greenPanel.addEast(new Label("Green East"), 50);
greenPanel.add(new Label("Green Center"));
SplitLayoutPanel redPanel = new SplitLayoutPanel();
redPanel.addStyleName("red");
redPanel.addNorth(new Label("Red North"), 50);
redPanel.add(new Label("Red Center"));
StyleInjector.inject(".green.gwt-SplitLayoutPanel .gwt-SplitLayoutPanel-HDragger { background: green; }");
StyleInjector.inject(".green.gwt-SplitLayoutPanel .gwt-SplitLayoutPanel-VDragger { background: green; }");
StyleInjector.inject(".red.gwt-SplitLayoutPanel .gwt-SplitLayoutPanel-HDragger { background: red; }");
StyleInjector.inject(".red.gwt-SplitLayoutPanel .gwt-SplitLayoutPanel-VDragger { background: red; }");
RootLayoutPanel rlp = RootLayoutPanel.get();
rlp.add(greenPanel);
rlp.setWidgetTopHeight(greenPanel, 0, PX, 50, PCT);
rlp.add(redPanel);
rlp.setWidgetBottomHeight(redPanel, 0, PX, 50, PCT);
因此,只是爲了闡明您的應用程序中有多個拆分佈局面板,並且您想要設計一個與另一個不同的佈局面板? – LINEMAN78 2011-01-05 19:37:19
是的,確切地說,我想以不同的樣式進行多個分割佈局面板 – user26270 2011-01-05 20:27:16