0

我有两个类 DocumentManagertwoApplication.java 和 DocumentEditor.java (代码如下)。当我点击“编辑”按钮时,我需要一些帮助来解决我得到的这个错误

com.vaadin.event.ListenerMethod$MethodException:在 com.example.documentmanagertwo.DocumentmanagertwoApplication$1 中调用方法 buttonClick 失败。在 com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:532) 在 com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164) 在 com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219 ) at com.vaadin.ui.Button.fireClick(Button.java:550) at com.vaadin.ui.Button.changeVariables(Button.java:217) at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.changeVariables( AbstractCommunicationManager.java:1455) 在 com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1399) 在 com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.handleVariables)

///////////////////////////////////////// ////////////////////////////////// DocumentManager两个应用代码如下:

FilesystemContainer docs = new FilesystemContainer (new File("C:\\Users\\MYRA\\Desktop\\Docx4java\\docs"));
Table selector = new Table (null, docs);
Label viewer = new Label ("Select a doc", Label.CONTENT_RAW);
Button edit = new Button ("edit");


@Override
public void init() {
    final Window mainWindow = new Window("Documentmanagertwo Application", new VerticalSplitPanel());
    VerticalLayout lo = new VerticalLayout();
    Label label = new Label("Hello Vaadin user");
    mainWindow.addComponent(label);
    mainWindow.addComponent(selector);
    lo.addComponent(viewer);
    lo.addComponent(edit);
    mainWindow.addComponent(lo);
    setMainWindow(mainWindow);

    edit.addListener(new Button.ClickListener (){


        private static final long serialVersionUID = -3024072268109652498L;

        public void buttonClick(ClickEvent event ) {

            Window dialog = new Window ("Edit Selected", 
                    new DocumentEditor(viewer.getPropertyDataSource()));
            dialog.setModal(true);
            mainWindow.addWindow (dialog);

        }


    });

    selector.setImmediate(true);
    selector.setSizeFull();
    selector.setSelectable(true);
    selector.addListener(new Property.ValueChangeListener()  {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            viewer.setPropertyDataSource(new TextFileProperty((File) selector.getValue()));
        }

    });
}

}

///////////////////////////////////////// /////////////////////////////////DocumentEditor.java 代码如下://// ///////////////////////////////////////// //////////////////////////

@AutoGenerated
private AbsoluteLayout mainLayout;

@AutoGenerated
private Button button_1;

@AutoGenerated
private RichTextArea richTextArea_1;

/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */



/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

/**
 * 
 */
private static final long serialVersionUID = 2788446877665474591L;
/**
 * The constructor should first build the main layout, set the
 * composition root and then do any custom initialization.
 *
 * The constructor will not be automatically regenerated by the
 * visual editor.
 */
public DocumentEditor(Property document) {
    buildMainLayout();
    setCompositionRoot(mainLayout);

    // TODO add user code here
    richTextArea_1.setPropertyDataSource(document);
    richTextArea_1.setWriteThrough(false);

    button_1.addListener(new Button.ClickListener()  {


        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event ) {
            richTextArea_1.commit();
            getApplication().getMainWindow().removeWindow(getWindow());
        }
    });

}

@AutoGenerated
private AbsoluteLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new AbsoluteLayout();
    mainLayout.setImmediate(false);
    mainLayout.setWidth("100%");
    mainLayout.setHeight("100%");
    mainLayout.setMargin(false);

    // top-level component properties
    setWidth("100.0%");
    setHeight("100.0%");

    // richTextArea_1
    richTextArea_1 = new RichTextArea();
    richTextArea_1.setImmediate(false);
    richTextArea_1.setWidth("572px");
    richTextArea_1.setHeight("360px");
    mainLayout.addComponent(richTextArea_1, "top:0.0px;left:-2.0px;");

    // button_1
    button_1 = new Button();
    button_1.setCaption("Save");
    button_1.setImmediate(false);
    button_1.setWidth("-1px");
    button_1.setHeight("-1px");
    mainLayout.addComponent(button_1, "top:360.0px;left:500.0px;");

    return mainLayout;
}

}

4

1 回答 1

0

异常的根本原因是 Caused by: java.lang.ClassNotFoundException: com.example.documentmanagertwo.DocumentEditor

这意味着 JVM 无法找到或加载给定的类。

DocumentEditor 是否从不在类路径上的库中导入任何类或路径?这通常是导致此问题的原因。

编译的类在类路径中吗?我会尝试清理和重建我的项目。

于 2012-06-08T06:49:31.720 回答