Minimize project on Button Click

I would like to minimize my FPMI project in code on a button click or menu item selection. Is this possible? I am running a project in full screen mode and allow the user to link to an email page that is opened in a browser window. When I do that the FPMI project is minimized and the user can interact with their email. When they minimize the email, then they have no way to get back to it again without using windows controls. I would like to allow them to minimize the project, which would display their email browser again.

Thanks,
Ron

There aren’t any built-in controls to switch between various window states (full-screen, normal, minimized, etc), but like so many things, you should be able to do this with some clever scripting.

[code]from javax.swing import JFrame
from javax.swing import SwingUtilities
from java.awt import GraphicsEnvironment

Grab the parent frame

frame = SwingUtilities.getAncestorOfClass(JFrame, event.source)

Get the screen device

screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()

Exit full-screen mode

screen.setFullScreenWindow(None)

Minimize the frame. 1 == java.awt.Frame.ICONIFIED

frame.setExtendedState(1)[/code]

Hope this helps,

That works great Carl, but when I restore the window it is no longer in full screen mode. Is it possible to reset it to full screen so when they click on the minimized project, it returns to full screen mode?

Thanks,
Ron

Ok, now things get really fun. In order to do this, you add a window listener to the frame that listens for when the frame becomes “deiconified” (restored), and then re-enters fullscreen mode. You only want to add this listener the 1st time you minimize, after that it will stay on the window for the lifetime of the client listening for deiconified events.

[code]from javax.swing import JFrame
from javax.swing import SwingUtilities
from java.awt import GraphicsEnvironment
from java.awt.event import WindowAdapter

Grab the parent frame

frame = SwingUtilities.getAncestorOfClass(JFrame, event.source)

Get the screen device

screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()

Exit full-screen mode

screen.setFullScreenWindow(None)

Minimize the frame. 1 == java.awt.Frame.ICONIFIED

frame.setExtendedState(1)
print “Exiting fullscreen mode”

If this is the 1st time we’ve ever been run, add a listener

to the frame to go back into fullscreen mode when we get

restored from minimized mode

global firstRun
try:
if firstRun:
firstRun=0
except NameError:
firstRun=1

class ReFullscreen(WindowAdapter):
def windowDeiconified(self, evt):
def goFull(event=evt):
from javax.swing import JFrame
from javax.swing import SwingUtilities
from java.awt import GraphicsEnvironment
# Grab the parent frame
frame = SwingUtilities.getAncestorOfClass(JFrame, event.source)
# Get the screen device
screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
# Re-enter full-screen mode
print “Re-entering fullscreen mode”
screen.setFullScreenWindow(frame)

	import fpmi
	fpmi.system.invokeLater(goFull)

if firstRun:
print “Adding window listener to re-enter fullscreen mode”
frame.addWindowListener(ReFullscreen())[/code]