0

I have downloaded the Vaadin Colorpicker addon to try it out , there is a small problem if i klick the colorPicker "Button" twice i get an IllegalArgumentException :

Exception

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)

Another question :

I want the colorPicker window to popup if I click on an item in a Menu something like if i click on "set Color" i get the colorPicker window. its quite hard to place the button on my GUI :P

EDIT :

Im adding the ColorPicker like this :

    colorPicker = new ColorPicker();
    colorPicker.setButtonCaption("Set Color");
    colorPicker.setRGBVisibility(false);
    colorPicker.setHSVVisibility(false);
    colorPicker.setHistoryVisibility(false);
    colorPicker.addListener(this);
    window.addComponent(colorPicker);
2
  • Can you post how you are adding the color picker in your code? Jan 30, 2012 at 17:44
  • @Terrell Plotzki Edited the question.
    – Kiesa
    Jan 31, 2012 at 7:44

1 Answer 1

2

I think you should try this code in your application:

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);
    }
}

If it doesn't work, then there is a defect in ColorPicker (and you could report a defect here: http://dev.vaadin.com/).

If the code above works, the problem is in your code then (in this case, share with us more of your code - you can even share whole class for).

2
  • I've run some tests and found out that i get the exception only after recovering the colorpicker after a relogg(restore Preferences) befor that it works normaly.
    – Kiesa
    Jan 31, 2012 at 12:38
  • What do you mean by " recovering the colorpicker after a relogg(restore Preferences)", could you share your code? that could be more explicit and accurate. You copy/paste your code here: pastebin.com Jan 31, 2012 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.