我已经下载了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);
最佳答案
我认为您应该在应用程序中尝试以下代码:
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/)。
如果上面的代码有效,那么问题出在您的代码中(在这种情况下,与我们分享更多的代码-您甚至可以共享整个类)。