gpt4 book ai didi

java - Vaadin ColorPicker IllegalArgumentException

转载 作者:行者123 更新时间:2023-12-02 07:59:49 27 4
gpt4 key购买 nike

我已经下载了 Vaadin Colorpicker 插件来尝试一下,如果我点击 colorPicker“按钮”两次,就会出现一个 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);

最佳答案

我认为您应该在应用程序中尝试此代码:

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/ )。

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

关于java - Vaadin ColorPicker IllegalArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9065818/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com