Monday, March 25, 2013

How to maximize and minimize windows in ZK .



Index.zul
<?page title="demo1" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="demo1" border="normal" id="browserDemo">
                <zscript><![CDATA[
                                import org.zkoss.zk.ui.event.EventListener;
                                Window window;
                                int counter = 0;
                                public void openBrowser() {
                                                window = (Window)Executions.createComponents("Browser.zul",null,null);
                                                window.setTitle("Browser Window-" + (counter+1));
                                                window.setId("Win" + (counter+1));
                                                window.setHeight("500px");
                                                window.setWidth("500px");
                                                window.setTop( (counter+(10*Math.random())) + "px");
                                                window.setLeft((counter+(20*Math.random())) + "px");
                                                window.addEventListener(Events.ON_CLOSE, new EventListener() {
                                                                public void onEvent(Event event) {
                                                                                String id = "Btn" + event.getTarget().getId();
                                                                                if(winList.getFellowIfAny(id) != null) {
                                                                                                winList.removeChild(winList.getFellow(id));
                                                                                }
                                                                }
                                                });
                                                Button btn = new Button("Window-" + (counter+1) );
                                                btn.setId("BtnWin" + (counter+1));
                                                btn.addEventListener("onClick", new EventListener() {
                                                                public void onEvent(Event event) {
                                                                                String id = event.getTarget().getId().substring(3);
                                                                                if(winList.getFellowIfAny(id) != null) {
                                                                                                if(((Window) winList.getFellowIfAny(id)).isMinimized() ) {
                                                                                                                ((Window) winList.getFellowIfAny(id)).setVisible(true);
                                                                                                }
                                                                                }
                                                                }
                                                });
                                                window.setParent(winList);
                                                btn.setParent(winList);
                                                counter++;
                                }
                                ]]>
                </zscript>
                <button label="browser" onClick="openBrowser()"></button>
                <hbox id="winList"></hbox>
 </window>
</zk>
Browser.zul
<?page title="Browser" contentType="text/html;charset=UTF-8"?>
<zk>
<window border="normal" shadow="false" closable="true" focus="true" maximizable="true"
  minimizable="true" mode="overlapped" sizable="true">
<iframe width="100%" height="100%" src="http://www.google.com"> </iframe>
</window>
</zk>

Demo here

No comments:

Post a Comment

How ChatGPT can Benefit Coding: Your Guide to Leveraging an AI Language Model

 Introduction: Hello, coders! Welcome to this blog post on how ChatGPT, an AI language model, can benefit your coding skills and projects. A...