Modal Pop-Up How-To?

Alright, who is ready for some hacking?

This might get complicated, but here is how I have achieved this in the past.

As an example, I will use my custom lock screen, attached in this post.

Here is the script.

def lockScreen():
	from javax.swing import SwingUtilities,JFrame		#Import some stuff
	import system.nav
	if system.util.getGlobals().has_key('lockScreen'):	#Check if the screen has been locked before.  This really just saves the set up code
		system.util.getGlobals()["app"].getRootPane().getGlassPane().visible = True				#Make the glass pane visible
		system.util.getGlobals()["lockScreen"].visible = True									#Make the lock screen visible
	else:	
		lockScreen = system.nav.openWindow('Lock Screen')										#Open the lock screen once.  To get a reference to the window
		system.util.getGlobals()["lockScreen"] = lockScreen										#Set a global variable referencing that instance
		app = SwingUtilities.getAncestorOfClass(JFrame, lockScreen)								#Get the app pane
		system.util.getGlobals()["app"] = app													#Set a reference to the app pane
		system.nav.closeWindow('Lock Screen')													#Close the window.  We have a reference now
		lockScreen.setDefaultCloseOperation(lockScreen.DISPOSE_ON_CLOSE)						#Set window close action
		app.getRootPane().getGlassPane().visible = True											#Make the glass pane visible
		app.getRootPane().getGlassPane().add(lockScreen)										#Add the custom  screen to the glass pane
		lockScreen.visible = True																#Make the window visible.

The main thing you have to change here is the window you open for the lockScreen. This window will open in the glass pane, covering everything else. How you decorate the window is up to you.

This is code I had in FPMI, so from when I was first learning Python. I will see if I can clean it up.

Let me know if you have any questions.
Lock Screen_2017-09-03_2341.proj (12.5 KB)

3 Likes