Vaadin ColorPicker IllegalArgumentException

时间:2012-01-30 14:56:10

标签: java vaadin

我已经下载了Vaadin Colorpicker插件试试看,如果我将colorPicker“Button”两次点击我会得到一个IllegalArgumentException,这是一个小问题:

异常

java.lang.IllegalArgumentException: Window was already added to application - it can not be added to another window also.
    at com.vaadin.ui.Window.addWindow(Window.java:1447)
    at com.vaadin.addon.colorpicker.ColorPicker.changeVariables(Unknown Source)
    at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1299)
    at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1219)
    at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:735)

另一个问题:

如果我单击菜单中的某个项目,如果单击“设置颜色”,我希望弹出colorPicker窗口,我得到了colorPicker窗口。很难将按钮放在我的GUI上:P

编辑:

我像这样添加ColorPicker:

    colorPicker = new ColorPicker();
    colorPicker.setButtonCaption("Set Color");
    colorPicker.setRGBVisibility(false);
    colorPicker.setHSVVisibility(false);
    colorPicker.setHistoryVisibility(false);
    colorPicker.addListener(this);
    window.addComponent(colorPicker);

1 个答案:

答案 0 :(得分:2)

我认为你应该在你的应用程序中尝试这个代码:

public class MyApplication extends Application {

    @Override
    public void init() {
        Window mainWindow = new Window("Your Application");

        // Create a color picker
        ColorPicker cp = new ColorPicker("ColorPicker", Color.RED);

        // Add a color change listener to the color picker
        cp.addListener(new ColorPicker.ColorChangeListener() {
            @Override
            public void colorChanged(ColorChangeEvent event) {
                MyApplication.this.getMainWindow()
                .showNotification("Color changed!");
            }
        });

        mainWindow.addComponent(cp);
        setMainWindow(mainWindow);
    }
}

如果它不起作用,则ColorPicker中存在缺陷(您可以在此处报告缺陷:http://dev.vaadin.com/)。

如果上面的代码有效,那么问题出现在您的代码中(在这种情况下,请与我们分享更多代码 - 您甚至可以共享整个类)。