Applet in a modal window with borderlayout

asked 2013-02-12 16:45:57 +0800

ebourgeois gravatar image ebourgeois
0 1

updated 2013-02-20 17:32:17 +0800

Hello All, Here is my problem. I have two windows, the mainWindow and the modalWindow. In the mainWindow there is an applet loaded. In the modalWindow there is also an applet, and I would like to use a borderlayout for the modal window’s layout. However, when the applet in the modal window is inside a borderlayout it doesn’t show up on screen. If I remove the borderlayout it works fine. I am not sure if this is a bug with the borderlayout or not, but I wanted to check if anyone else had this issue and if there was something I wasn't doing right?

Here is the code zul for the "mainWindow":

<window title="Main Window" border="normal" height="100%" width="100%" apply="org.zkoss.bind.BindComposer" mode="embedded" id="mainWindow" viewmodel="@id('vm') @init('dualapplet.IndexViewModel')">
            <label value="You are using: ${desktop.webApp.version}"/>
            <button id="modal" onclick="@command('doModal')">Modal No Border Layout</button>
            <button id="modalBL" onclick="@command('doModalBorderLayout')">Modal with Border Layout</button>
<applet id="applet1" code="main.java.dualapplet.AppletOne" codebase="/resources" archive="dualapplet-jar-with-dependencies.jar" height="100%" width="100%" autohide="true"></applet>
</borderlayout> </window>

Here is the zul for the modal window:

<window title="Modal Window" border="normal" width="880px" height="490px" closable="true">
    <borderlayout apply="org.zkoss.bind.BindComposer" viewmodel="@id('vm') @init('dualapplet.ModalViewModel')">
                <label value="You are Modal with a BorderLayout"/>
<applet id="applet2" code="main.java.dualapplet.AppletTwo" codebase="/resources" width="100%" height="100%" archive="dualapplet-jar-with-dependencies.jar"></applet>
</borderlayout> </window>

Thanks, Etienne

Here are some more details, in the hope that someone somewhere has a lightbulb moment!!! :)

Instead of calling doModal() I tried doEmbedded(), and the applet inside the window being opened didn't show up. When I open the "modal" zul page directly in the browser (i.e. by typing the page address in the browser's address bar) then it works fine.

This is the code I use to opened the window.

Window window = (Window) Executions.createComponents("modalWindow.zul", null, null);
try {
} catch (SuspendNotAllowedException e) {
   Messagebox.show("Error: " + e.getMessage());
   throw new RuntimeException(e);

But still when not using a border layout, the applet shows up fine. It is strange.

delete flag offensive retag edit


I have double checked and the <center> tags are there in my code, I screwed up the copy-paste in the question, but thanks for noticing.

ebourgeois ( 2013-02-13 15:11:39 +0800 )edit

jj, I tried to set the vflex and the hflex = "1" but no luck, however, it now works when I use the doEmbedded as opposed to doModal. Thanks some progress!

ebourgeois ( 2013-02-14 14:25:46 +0800 )edit

3 Answers

Sort by » oldest newest most voted

answered 2013-02-13 00:41:48 +0800

spitghost gravatar image spitghost

updated 2013-02-13 00:42:10 +0800

Hey Etienne,

Since your applet is inside a borderlayout, have you tried to put your applet tag inside a borderlayout center tag?


link publish delete flag offensive edit

answered 2013-02-14 06:32:38 +0800

jj gravatar image jj
638 3

updated 2013-02-14 06:32:55 +0800

set the vflex and hflex = "1" for the center element

link publish delete flag offensive edit

answered 2013-02-20 17:32:25 +0800

ebourgeois gravatar image ebourgeois
0 1


I finally figured this out. Short answer is to take the Border layout out of the modal window, and put it in its own .zul file and then load this zul file in an iframe in the modal window. This in effect creates a second desktop which allows the modal applet to display.

Here is my theory as to what is happening. In the main window, I used the zk.useStackup setting to prevent the applet from hiding options in my menu bar, and I also use the autohide attribute to hide the applet.

As far as I can tell this also causes the applet in the modal window to hide itself when there is a control over the main window applet. In this case the modal window is causing the main window's applet from being displayed, and this hiding of the main window applet seems to bubble up to the modal window's applet.

When using an iframe a new desktop is created and therefore no communication can happen between the main window and the iframe contents, therefore the modal applet is no longer being hidden. In order to send events back to my main application from the modal window's iframe contents, I used a GROUP scoped EventQueue.

I hope this all makes sense, thanks to spitghost and jj for your help, your comments put me on the right track.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2013-02-12 16:45:57 +0800

Seen: 45 times

Last updated: Feb 20 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More