Do you mean full screen mode where the window fills the whole screen with no title bar? If so, the code below on a button will swap the desktop the button is contained in between full screen and windowed modes.
from javax.swing import JFrame
window = system.gui.getParentWindow(event)
while not isinstance(window, JFrame):
window = window.getParent()
if window.isUndecorated():
# Switch to windowed mode.
window.dispose()
window.setUndecorated(False)
window.setExtendedState(JFrame.NORMAL)
# Restore previous window size and location, if available.
try:
normalW = event.source.getClientProperty('normalW')
normalH = event.source.getClientProperty('normalH')
normalX = event.source.getClientProperty('normalX')
normalY = event.source.getClientProperty('normalY')
window.setSize(normalW, normalH)
window.setLocation(normalX, normalY)
except:
pass
window.setVisible(True)
else:
# Store window size and location for restore.
event.source.putClientProperty('normalW', window.size.width)
event.source.putClientProperty('normalH', window.size.height)
event.source.putClientProperty('normalX', window.x)
event.source.putClientProperty('normalY', window.y)
# Switch to full screen mode.
window.dispose()
window.setUndecorated(True)
window.setExtendedState(JFrame.MAXIMIZED_BOTH)
window.setVisible(True)