public class SplitPanelTest {
public void test(){
int splitterSize = 5; //I wanted to have a 5px-size splitter
SplitLayoutPanel splitPanel = new SplitLayoutPanel(splitterSize);
splitPanel.addWest(new HTML("<b>Copyright © 2008</b>"), 300);
splitPanel.addEast(new Label("TEST222222222222"), 300);
//RootPanel.get().add(splitPanel); //my first approach
// RootLayoutPanel panel = RootLayoutPanel.get(); //my second approach
// panel.add(splitPanel);
}
}
public class TaskFormEntryPoint implements EntryPoint {
public void onModuleLoad() {
SplitPanelTest p = new SplitPanelTest ();
p.test();
}
}
我在代码中插入了小修正案。现在它看起来像这样:
public class TaskFormEntryPoint implements EntryPoint {
@Override
public void onModuleLoad() {
SplitPanelTest sp = new SplitPanelTest();
sp.test();
}
}
public class SplitPanelTest {
public void test(){
int splitterSize = 5;
SplitLayoutPanel splitPanel = new SplitLayoutPanel(splitterSize);
splitPanel.getElement().getStyle().setProperty("border", "5px solid #F00");
splitPanel.addWest(new Label("left"), 300);
splitPanel.add(new Label("right"));
RootLayoutPanel panel = RootLayoutPanel.get();
panel.add(splitPanel);
}
}
我解决了这个问题。我插入了StyleInjector类:
public class SplitPanelTest {
public void test(){
int splitterSize = 5;
SplitLayoutPanel splitPanel = new SplitLayoutPanel(splitterSize);
splitPanel.getElement().getStyle().setProperty("border", "5px solid #F00");
splitPanel.addWest(new Label("left"), 300);
splitPanel.add(new Label("right"));
StyleInjector.inject(".gwt-SplitLayoutPanel .gwt-SplitLayoutPanel-HDragger "
+ "{ width: 5px !important; background: green; }");
RootLayoutPanel panel = RootLayoutPanel.get();
panel.add(splitPanel);
}
}
现在我可以将分割器看作5px宽度的绿线。 谢谢大家!