Modal windows

Is it possible to make a FactoryPMI window modal? I am using a small window as a popup with further controls on it - for example when a user clicks on a tank, they are given the option to set the temperature up or down.

The problem I have is that the user can still interact with the parent window. Normally, clicking on the parent window will hide the popup window, even though it is still open. Making the popup window modal would stop any further interaction until the popup was closed.

To prevent the window from disappearing, you can set the layer of the popup window to a value greater than the background window. This will prevent it from disappearing when you click the window behind it


Thanks for your help. I was speaking to Travis about another point when I mentioned your idea. He came back with a development to stop access to any controls on the background window while the popup is open.

  1. Develop your popup as a maximised window, with all controls in a container with a coloured background.
  2. Put the following script in the window’s internalFrameActivated event:

window = fpmi.gui.getParentWindow(event) window.setOpaque(0)
3. Set the layer of the popup window to a value greater than the background window.

Now when the popup is displayed, you can still see the background window , but you cannot click on any of its controls.


Thank you for posting this solution. I also had a similar need for a popup to always be on top. This method worked for me, after a little tweaking for my application.

Thanks again,


I am developing a system which implements modal ‘popups’ using the technique I previously mentioned in this thread. However, I am now using an interface with a navigation bar docked north, with the main window filling the rest of the screen.

When I open the popup, it only covers the main part of the window, meaning that the user can still press buttons on the buttonbar. Is there any way to force the popup to occupy the whole screen even if there are docked windows present? I tried changing the window layer, but without success.

No, floating windows cannot cover docked windows. You can close the docked window and open it when necessary or disable any components on the docked window.

I’ll add my kudos to Al and Travis for this. It’s an interesting trend on how many of us are doing pop-ups… :wink:

I know this is a really old thread now, but if anyone else stumbles across it like I did looking for a solution, here’s what I did:
(WARNING: it’s a bit of a messy hack, but worked for me)

def showModal(windowPath, params=None):
	from javax.swing import JDialog
	window = system.nav.openWindowInstance(windowPath, params)
	rc = window.getRootContainer()
	cp = window.getContentPane()
	dlg = JDialog(None, True)
	dlg.setSize(window.getWidth(), window.getHeight())
	return rc.Result

The root container should have a custom property called “Result” whose value is set, e.g. from a input text field, etc.

If the window has a ‘Close’ button etc on it, I had to define and call the following function to make it work as a modal dialog:

def close(event):
		from javax.swing import SwingUtilities
		from java.awt.event import WindowEvent
		frame = SwingUtilities.getWindowAncestor(event.source)
		frame.dispatchEvent(WindowEvent(frame, WindowEvent.WINDOW_CLOSING))

The solution works very well. Thanks for your effort!

1 Like

It works very well , thanks.