GWT:SplitLayoutPanel:我没看到分离器

时间:2013-05-03 12:11:59

标签: java gwt

抱歉,有什么问题?我只看到西部和东部。我想使用Horizo​​ntalSplitPanel,但它已被弃用。我没有在两个部分之间看到任何5px大小的分割器:

   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 &copy; 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宽度的绿线。 谢谢大家!

0 个答案:

没有答案