2009-11-07 67 views
0

我使用gwt連接器爲我的項目,我試圖每次單擊按鈕時創建新的連接器。下面是代碼:問題創建新connectore

public class ERD1 implements EntryPoint { 

public void onModuleLoad() { 

    AbsolutePanel boundaryPanel = new AbsolutePanel(); 
    boundaryPanel.setPixelSize(1000, 1000); 

    final Diagram d = new Diagram(boundaryPanel); 

    Button b = new Button(); 
    b.addClickListener(new ClickListener(){ 

     @Override 
     public void onClick(Widget sender) { 
      SectionDecoration startDecoration = new SectionDecoration 
      (SectionDecoration.DECORATE_ARROW); 
        SectionDecoration endDecoration = new SectionDecoration 
      (SectionDecoration.DECORATE_ARROW); 

      Connector con = new Connector(10, 10, 10, 10, startDecoration, endDecoration); 
      con.showOnDiagram(d); 
     } 

    }); 

    boundaryPanel.add(b, 10, 40); 

    RootPanel.get().add(boundaryPanel); 
} 
} 

但是當我點擊按鈕我收到以下錯誤:

[ERROR] Uncaught exception escaped 
java.lang.IllegalArgumentException: Sections must be horizontal or vertical! 
    at pl.tecna.gwt.connectors.client.Section.<init>(Section.java:44) 
    at pl.tecna.gwt.connectors.client.Connector.recreateSections(Connector.java:226) 
    at pl.tecna.gwt.connectors.client.Connector.showOnDiagram(Connector.java:162) 
    at com.e.r.d.client.ERD1$1.onClick(ERD1.java:45) 
    at com.google.gwt.user.client.ui.ListenerWrapper$WrappedClickListener.onClick(ListenerWrapper.java:245) 
    at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:54) 
    at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1) 
    at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65) 
    at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53) 
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178) 
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:52) 
    at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116) 
    at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:90) 
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1320) 
    at com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:1299) 
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1262) 
    at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) 
    at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126) 
    at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155) 
    at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294) 
    at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194) 
    at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117) 
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) 
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925) 
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966) 
    at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:264) 
    at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:557) 
    at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405) 
    at com.google.gwt.dev.HostedMode.main(HostedMode.java:232) 

請誰能告訴我什麼錯誤。 謝謝。

回答

0

看來你所有的觀點都在同一點。如何嘗試不同的觀點?就像說Connector con = new Connector(10, 15, 29, 100, startDecoration, endDecoration); 什麼的。

0

我覺得出了什麼問題。

Connector con = new Connector(10, 10, 10, 10, startDecoration, endDecoration); 

這裏我有10,10,10,10彼此重疊。這是錯誤的原因。