public class PortingUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static boolean |
INITIALIZE_SCREEN_AREA_USING_THREAD |
Constructor and Description |
---|
PortingUtils() |
Modifier and Type | Method and Description |
---|---|
static java.awt.Rectangle |
containsInScreenBounds(java.awt.Component invoker,
java.awt.Rectangle rect)
To make sure the rectangle is within the screen bounds.
|
static java.awt.Rectangle |
ensureOnScreen(java.awt.Rectangle rect)
Modifies the position of rect so that it is completely on screen if that is possible.
|
static java.awt.Rectangle |
ensureVisible(java.awt.Component invoker,
java.awt.Rectangle bounds)
Ensures the rectangle is visible on the screen.
|
static java.awt.Rectangle |
getContainingScreenBounds(java.awt.Rectangle rect,
boolean considerInsets)
Gets the screen bounds that contains the rect.
|
static java.awt.Component |
getCurrentFocusComponent(java.awt.AWTEvent event)
Gets current focused components.
|
static int |
getFrameState(java.awt.Frame frame)
Gets frame's state.
|
static java.awt.Rectangle |
getLocalScreenBounds()
Gets the local monitor's screen bounds.
|
static java.awt.Dimension |
getLocalScreenSize(java.awt.Component invoker)
Gets the screen size.
|
static int |
getMouseModifiers(java.awt.event.MouseEvent e)
Gets mouse modifiers.
|
static java.awt.geom.Area |
getScreenArea()
Get screen area of all monitors.
|
static java.awt.Rectangle |
getScreenBounds(java.awt.Component invoker)
Gets the screen bounds.
|
static java.awt.Dimension |
getScreenSize(java.awt.Component invoker)
Gets the screen size.
|
static void |
initializeScreenArea()
If you use methods such as
ensureOnScreen(java.awt.Rectangle) , getContainingScreenBounds(java.awt.Rectangle,boolean) or getScreenArea() for the first time, it will
take up to a few seconds to run because it needs to get device information. |
static void |
initializeScreenArea(int priority)
If you use methods such as
ensureOnScreen(java.awt.Rectangle) , getContainingScreenBounds(java.awt.Rectangle,boolean) or getScreenArea() for the first time, it will
take up to a couple of seconds to run because it needs to get device information. |
static boolean |
isInitalizationThreadStarted() |
static boolean |
isInitializationThreadAlive() |
static void |
notifyUser()
Notifies user something is wrong.
|
static void |
notifyUser(java.awt.Component component)
Notifies user something is wrong.
|
static java.awt.Rectangle |
overlapWithScreenBounds(java.awt.Component invoker,
java.awt.Rectangle rect)
To make sure the rectangle has overlap with the screen bounds.
|
static void |
prerequisiteChecking()
Checks the prerequisite needed by JIDE demos.
|
static void |
removeButtonBorder(javax.swing.AbstractButton button)
Removes the button border.
|
static void |
removeFocus(javax.swing.JComponent component)
Makes sure the component won't receive the focus.
|
static void |
setFrameState(java.awt.Frame frame,
int state)
Sets frame's state.
|
static void |
setMinimumSize(java.awt.Component component,
java.awt.Dimension size)
Sets the minimum size on a component.
|
static void |
setPreferredSize(java.awt.Component component,
java.awt.Dimension size)
Sets the preferred size on a component.
|
public static boolean INITIALIZE_SCREEN_AREA_USING_THREAD
public static java.awt.Component getCurrentFocusComponent(java.awt.AWTEvent event)
event
- public static int getFrameState(java.awt.Frame frame)
frame
- public static void setFrameState(java.awt.Frame frame, int state)
frame
- state
- public static int getMouseModifiers(java.awt.event.MouseEvent e)
e
- public static void removeFocus(javax.swing.JComponent component)
component
- public static void removeButtonBorder(javax.swing.AbstractButton button)
button
- public static java.awt.Rectangle containsInScreenBounds(java.awt.Component invoker, java.awt.Rectangle rect)
invoker
- rect
- public static java.awt.Rectangle overlapWithScreenBounds(java.awt.Component invoker, java.awt.Rectangle rect)
invoker
- rect
- public static java.awt.Dimension getScreenSize(java.awt.Component invoker)
invoker
- public static java.awt.Dimension getLocalScreenSize(java.awt.Component invoker)
invoker
- public static java.awt.Rectangle getScreenBounds(java.awt.Component invoker)
invoker
- public static java.awt.Rectangle getLocalScreenBounds()
public static void initializeScreenArea()
ensureOnScreen(java.awt.Rectangle)
, getContainingScreenBounds(java.awt.Rectangle,boolean)
or getScreenArea()
for the first time, it will
take up to a few seconds to run because it needs to get device information. To avoid any slowness, you can call
call initializeScreenArea()
method in the class where you will use those three methods. This method will
spawn a thread to retrieve device information thus it will return immediately. Hopefully, when you use the three
methods, the thread is done so user will not notice any slowness.public static void initializeScreenArea(int priority)
ensureOnScreen(java.awt.Rectangle)
, getContainingScreenBounds(java.awt.Rectangle,boolean)
or getScreenArea()
for the first time, it will
take up to a couple of seconds to run because it needs to get device information. To avoid any slowness, you can
call initializeScreenArea()
method in the class where you will use those three methods. This method will
spawn a thread to retrieve device information thus it will return immediately. Hopefully, when you use the three
methods, the thread is done so user will not notice any slowness.priority
- as we will use a thread to calculate the screen area, you can use this parameter to control the
priority of the thread. If you are waiting for the result before the next step, you should use
normal priority (which is 5). If you just want to calculate when app starts, you can use a lower
priority (such as 3). For example, AbstractComboBox needs screen size so that the popup doesn't
go beyond the screen. So when AbstractComboBox is used, we will kick off the thread at priority
3. If user clicks on the drop down after the thread finished, there will be no time delay.public static boolean isInitializationThreadAlive()
public static boolean isInitalizationThreadStarted()
public static java.awt.Rectangle ensureVisible(java.awt.Component invoker, java.awt.Rectangle bounds)
invoker
- the invoking componentbounds
- the input boundspublic static java.awt.Rectangle ensureOnScreen(java.awt.Rectangle rect)
rect
- Therectanglee to move onto a single screenpublic static java.awt.Rectangle getContainingScreenBounds(java.awt.Rectangle rect, boolean considerInsets)
rect
- the rect of the component.considerInsets
- if consider the insets. The insets is for thing like Windows Task Bar.public static java.awt.geom.Area getScreenArea()
public static void notifyUser()
public static void notifyUser(java.awt.Component component)
component
- the component that has the error or null if the error is not associated with any component.public static void prerequisiteChecking()
public static void setPreferredSize(java.awt.Component component, java.awt.Dimension size)
component
- the componentsize
- the preferred size.public static void setMinimumSize(java.awt.Component component, java.awt.Dimension size)
component
- the componentsize
- the preferred size.