Inheriting Window

Inheriting Window


// Define a sub-window by inheritance
class MySub extends Window {
    public MySub() {
        super("Subs on Sale"); // Set window caption
        
        // Some content for the window
        addComponent(new Label("Hello there!"));

        // Trivial logic for closing the sub-window
        Button close = new Button("Close");
        close.addListener(new ClickListener() {
            public void buttonClick(ClickEvent event) {
                // Parent of a sub-window is the
                // application-level window.
                getWindow().getParent().removeWindow(getWindow());
            }
        });
        addComponent(close);
    }
}
        
// Some UI logic to open the sub-window
final Button open = new Button("Open Sub-Window");
open.addListener(new ClickListener() {
    public void buttonClick(ClickEvent event) {
        MySub sub = new MySub();
        
        // Add it to the main window, or more exactly the
        // current application-level window.
        getWindow().addWindow(sub);
    }
});

Esperar amb aquest… no esta complet!