Class SwingWindow
- java.lang.Object
-
- com.inductiveautomation.snap.swing.SwingWindow
-
public class SwingWindow extends java.lang.Object
A class to manage the Window of a SwingOwner.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SwingWindow.Pos
static class
SwingWindow.Style
-
Constructor Summary
Constructors Constructor Description SwingWindow()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addWindowListener(java.awt.event.WindowListener aListener)
Add window listener.protected java.awt.Window
createWindow()
Creates a window for this panel from window class.java.awt.Container
getContentPane()
Returns the content pane.java.util.concurrent.Callable<javax.swing.JComponent>
getContentPaneCall()
Returns the Callable that provides the ContentPane.javax.swing.JButton
getDefaultButton()
Returns the name of the default button associated with this window.java.io.File
getDocumentFile()
Returns the document file for the window title bar proxy icon.static java.io.File
getDocumentFile(java.awt.Window aWindow)
Returns the document file for the window title bar proxy icon.int
getHeight()
Returns the window x.java.awt.Image
getIconImage()
Returns the icon image for the window.javax.swing.JMenuBar
getMenuBar()
Returns the menu bar associated with this window.java.awt.Dimension
getMinimumSize()
Returns the window MinimumSize.java.awt.Dimension
getPreferredSize()
Returns the window PreferredSize.javax.swing.JRootPane
getRootPane()
Returns the root pane for the window.static javax.swing.JRootPane
getRootPane(java.awt.Window aWin)
Returns the root pane for a window, if available.java.awt.Dimension
getSize()
Returns the window size.SwingWindow.Style
getStyle()
Returns the window style.java.lang.String
getTitle()
Returns the title of the window.int
getWidth()
Returns the window width.java.awt.Window
getWindow()
Returns the window associated with this panel, creating it if necessary.java.util.concurrent.Callable<java.awt.Window>
getWindowCall()
Returns the call to create the window.java.lang.Class<? extends java.awt.Window>
getWindowClass()
Returns the class of the window associated with this panel.int
getX()
Returns the window x.int
getY()
Returns the window y.boolean
isAlwaysOnTop()
Returns whether the window is always on top.boolean
isHideOnDeactivate()
Returns whether the window will hide on deactivate.boolean
isModal()
Returns the modal mode of the window.boolean
isResizable()
Returns whether the window is resizable.boolean
isUndecorated()
Returns true if the window has no title bar or other decorations.boolean
isVisible()
Returns whether window is visible.boolean
isWindowSet()
Returns whether window has been created.void
pack()
Packs the window.void
requestFocus()
Requests focus on the window.void
setAlwaysOnTop(boolean aValue)
Sets whether the window is always on top.void
setContentPane(java.awt.Container aContainer)
Sets the content pane.void
setContentPaneCall(java.util.concurrent.Callable<javax.swing.JComponent> aCall)
Sets the Callable that provides the ContentPane.void
setDefaultButton(javax.swing.JButton aButton)
Sets the name of the default button associated with this window.static void
setDocumentFile(java.awt.Window aWindow, java.io.File aFile)
Returns the document file for the window title bar proxy icon.void
setDocumentFile(java.io.File aFile)
Returns the document file for the window title bar proxy icon.void
setHideOnDeactivate(boolean aValue)
Sets whether the window will hide on deacativate.void
setIconImage(java.awt.Image anImage)
Sets the icon image for the window.void
setMaximizedBounds(java.awt.Rectangle aRect)
Set Maximized bounds.void
setMenuBar(javax.swing.JMenuBar aMenuBar)
Sets the menu bar associated with this window.void
setModal(boolean aValue)
Sets the modal mode of the window (defaults to false).void
setResizable(boolean aValue)
Sets whether the window is resizable (default to true).void
setSize(java.awt.Dimension aSize)
Returns the window size.void
setStyle(SwingWindow.Style aStyle)
Sets the window style.void
setTitle(java.lang.String aValue)
Sets the title of the window.void
setUndecorated(boolean flag)
Sets whether the window has a title bar and decorations or not.void
setVisible(boolean aValue)
This method sets the window to be visible or invisible.void
setVisible(SwingWindow.Pos aPos, int x, int y, java.lang.String fsaveName, boolean doSize)
This method set the window associated with this panel to be visible at some given x and y away from a given corner.static void
setVisible(java.awt.Component aWin, SwingWindow.Pos aPos, int dx, int dy, java.lang.String aFrmSvName, boolean doSize)
Makes a window visible with the given corner at the given x & y.protected void
setWindow(java.awt.Window aWindow)
Sets a new window for this panel.void
setWindowCall(java.util.concurrent.Callable<java.awt.Window> aCall)
Sets the call to create the window.void
setWindowClass(java.lang.Class<? extends java.awt.Window> aClass)
Sets the window class.void
toFront()
Order window to front.void
windowDispose()
This method disposes the window associated with this panel.
-
-
-
Method Detail
-
isWindowSet
public boolean isWindowSet()
Returns whether window has been created.
-
getWindow
public java.awt.Window getWindow()
Returns the window associated with this panel, creating it if necessary.
-
setWindow
protected void setWindow(java.awt.Window aWindow)
Sets a new window for this panel.
-
createWindow
protected java.awt.Window createWindow()
Creates a window for this panel from window class.
-
getWindowCall
public java.util.concurrent.Callable<java.awt.Window> getWindowCall()
Returns the call to create the window.
-
setWindowCall
public void setWindowCall(java.util.concurrent.Callable<java.awt.Window> aCall)
Sets the call to create the window.
-
getContentPaneCall
public java.util.concurrent.Callable<javax.swing.JComponent> getContentPaneCall()
Returns the Callable that provides the ContentPane.
-
setContentPaneCall
public void setContentPaneCall(java.util.concurrent.Callable<javax.swing.JComponent> aCall)
Sets the Callable that provides the ContentPane.
-
getWindowClass
public java.lang.Class<? extends java.awt.Window> getWindowClass()
Returns the class of the window associated with this panel.
-
setWindowClass
public void setWindowClass(java.lang.Class<? extends java.awt.Window> aClass)
Sets the window class.
-
getTitle
public java.lang.String getTitle()
Returns the title of the window.
-
setTitle
public void setTitle(java.lang.String aValue)
Sets the title of the window.
-
isResizable
public boolean isResizable()
Returns whether the window is resizable.
-
setResizable
public void setResizable(boolean aValue)
Sets whether the window is resizable (default to true).
-
getStyle
public SwingWindow.Style getStyle()
Returns the window style.
-
setStyle
public void setStyle(SwingWindow.Style aStyle)
Sets the window style.
-
getMenuBar
public javax.swing.JMenuBar getMenuBar()
Returns the menu bar associated with this window.
-
setMenuBar
public void setMenuBar(javax.swing.JMenuBar aMenuBar)
Sets the menu bar associated with this window.
-
isAlwaysOnTop
public boolean isAlwaysOnTop()
Returns whether the window is always on top.
-
setAlwaysOnTop
public void setAlwaysOnTop(boolean aValue)
Sets whether the window is always on top.
-
getDocumentFile
public java.io.File getDocumentFile()
Returns the document file for the window title bar proxy icon.
-
setDocumentFile
public void setDocumentFile(java.io.File aFile)
Returns the document file for the window title bar proxy icon.
-
isHideOnDeactivate
public boolean isHideOnDeactivate()
Returns whether the window will hide on deactivate.
-
setHideOnDeactivate
public void setHideOnDeactivate(boolean aValue)
Sets whether the window will hide on deacativate.
-
getIconImage
public java.awt.Image getIconImage()
Returns the icon image for the window.
-
setIconImage
public void setIconImage(java.awt.Image anImage)
Sets the icon image for the window.
-
isModal
public boolean isModal()
Returns the modal mode of the window.
-
setModal
public void setModal(boolean aValue)
Sets the modal mode of the window (defaults to false).
-
getDefaultButton
public javax.swing.JButton getDefaultButton()
Returns the name of the default button associated with this window.
-
setDefaultButton
public void setDefaultButton(javax.swing.JButton aButton)
Sets the name of the default button associated with this window.
-
isUndecorated
public boolean isUndecorated()
Returns true if the window has no title bar or other decorations.
-
setUndecorated
public void setUndecorated(boolean flag)
Sets whether the window has a title bar and decorations or not. This must be done before the first call to getWindow() or an IllegalComponentStateException will be thrown.
-
addWindowListener
public void addWindowListener(java.awt.event.WindowListener aListener)
Add window listener.
-
getRootPane
public javax.swing.JRootPane getRootPane()
Returns the root pane for the window.
-
getContentPane
public java.awt.Container getContentPane()
Returns the content pane.
-
setContentPane
public void setContentPane(java.awt.Container aContainer)
Sets the content pane.
-
getX
public int getX()
Returns the window x.
-
getY
public int getY()
Returns the window y.
-
getWidth
public int getWidth()
Returns the window width.
-
getHeight
public int getHeight()
Returns the window x.
-
getSize
public java.awt.Dimension getSize()
Returns the window size.
-
setSize
public void setSize(java.awt.Dimension aSize)
Returns the window size.
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
Returns the window PreferredSize.
-
getMinimumSize
public java.awt.Dimension getMinimumSize()
Returns the window MinimumSize.
-
pack
public void pack()
Packs the window.
-
requestFocus
public void requestFocus()
Requests focus on the window.
-
toFront
public void toFront()
Order window to front.
-
setMaximizedBounds
public void setMaximizedBounds(java.awt.Rectangle aRect)
Set Maximized bounds.
-
windowDispose
public void windowDispose()
This method disposes the window associated with this panel.
-
isVisible
public boolean isVisible()
Returns whether window is visible.
-
setVisible
public void setVisible(boolean aValue)
This method sets the window to be visible or invisible.
-
setVisible
public void setVisible(SwingWindow.Pos aPos, int x, int y, java.lang.String fsaveName, boolean doSize)
This method set the window associated with this panel to be visible at some given x and y away from a given corner. It also allows you to provide a "frame save name" which causes the frame's location and size to be saved between sessions (in which case it will override the default position provided).
-
setVisible
public static void setVisible(java.awt.Component aWin, SwingWindow.Pos aPos, int dx, int dy, java.lang.String aFrmSvName, boolean doSize)
Makes a window visible with the given corner at the given x & y.
-
getRootPane
public static javax.swing.JRootPane getRootPane(java.awt.Window aWin)
Returns the root pane for a window, if available.
-
getDocumentFile
public static java.io.File getDocumentFile(java.awt.Window aWindow)
Returns the document file for the window title bar proxy icon.
-
setDocumentFile
public static void setDocumentFile(java.awt.Window aWindow, java.io.File aFile)
Returns the document file for the window title bar proxy icon.
-
-