Package at.ofai.music.util
Class FrameMargins
- java.lang.Object
-
- at.ofai.music.util.FrameMargins
-
public class FrameMargins extends java.lang.Object
Java has problems communicating with window managers like fvwm2. This class is a workaround to find the size of borders of JFrames in the current environment, so that programs can size their JFrames correctly. Since we don't know how big borders are until after the window is created, we create a dummy JFrame, query the size of its borders, and destroy it. The values are saved for later calls to this class, so that the dummy JFrame is only created once.
-
-
Field Summary
Fields Modifier and Type Field and Description protected static java.awt.Insets
i
protected static java.awt.Dimension
insetsWithMenu
protected static java.awt.Dimension
insetsWithoutMenu
protected static java.awt.Dimension
topLeftWithMenu
protected static java.awt.Dimension
topLeftWithoutMenu
-
Constructor Summary
Constructors Constructor and Description FrameMargins()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.awt.Dimension
get(boolean withMenuFlag)
Returns the total size of the insets of a JFrame, that is the size of the title bar, menu bar (if requested) and the borders of the JFrame.static java.awt.Insets
getFrameInsets()
Returns the Insets object for a JFrame.static java.awt.Dimension
getOrigin(boolean withMenuFlag)
Returns the location of the content pane with respect to its JFrame.
-
-
-
Field Detail
-
i
protected static java.awt.Insets i
-
insetsWithMenu
protected static java.awt.Dimension insetsWithMenu
-
insetsWithoutMenu
protected static java.awt.Dimension insetsWithoutMenu
-
topLeftWithMenu
protected static java.awt.Dimension topLeftWithMenu
-
topLeftWithoutMenu
protected static java.awt.Dimension topLeftWithoutMenu
-
-
Method Detail
-
get
public static java.awt.Dimension get(boolean withMenuFlag)
Returns the total size of the insets of a JFrame, that is the size of the title bar, menu bar (if requested) and the borders of the JFrame. In other words, the return value is the difference in size between the JFrame itself and its content pane.- Parameters:
withMenuFlag
- indicates whether a menu bar should be included in the calculations- Returns:
- the height and width of the insets of a JFrame, unless
getInsets()
returns a ridiculously large value, in which case we gracefully return a guess of (30,20).
-
getOrigin
public static java.awt.Dimension getOrigin(boolean withMenuFlag)
Returns the location of the content pane with respect to its JFrame.- Parameters:
withMenuFlag
- indicates whether a menu bar should be included in the calculations- Returns:
- the x and y offsets of the top left corner of the content pane from the top left corner of the JFrame
-
getFrameInsets
public static java.awt.Insets getFrameInsets()
Returns the Insets object for a JFrame.- Returns:
- the Insets object measuring the size of the borders of a JFrame
-
-