com.jidesoft.alert
Class AlertGroup
java.lang.Object
com.jidesoft.alert.AlertGroup
public class AlertGroup
- extends Object
AlertGroup
is used when showing multiple alerts at one time.
Alert
has an option to show at a particular location relative to the screen using JidePopup.showPopup(int)
. For example, if you call showPopup(SwingConstants.SOUTH_EAST)
, the alert will
appear at the bottom-right corner of the screen. If you show two alerts both at
SwingConstants.SOUTH_EAST
, the two alerts will overlap. In order to solve this issue, we introduce this
AlertGroup
. To use it, you just call add(Alert)
to add all alerts to AlertGroup
.
AlertGroup
will move the alert so that there are no overlap.
Although Alert
's showPopup(int location)
can support locations such as
SwingConstants.CENTER
, SwingConstants.NORTH
etc, AlertGroup
only handle the
following four locations - SwingConstants.SOUTH_EAST
, SwingConstants.SOUTH_WEST
,
SwingConstants.NORTH_EAST
and SwingConstants.NORTH_WEST
.
You can also remove an alert from AlertGroup
using remove(Alert)
. But if you don't call it, the
alert will be removed automatically when it is hidden.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AlertGroup
public AlertGroup()
add
public void add(Alert alert)
remove
public void remove(Alert alert)
isRegionOverlap
protected boolean isRegionOverlap(Alert alert,
Rectangle proposedBounds)
- Check if the alert at the proposed bounds will overlap with any existing visible alerts.
- Parameters:
alert
- the alert.proposedBounds
- the proposed bounds of the alert.
- Returns:
- true if overlaps. Otherwise, false.
getDisplayStartLocation
public Point getDisplayStartLocation(Alert alert,
Rectangle screenDim,
Dimension size,
int location,
int gap)
- Gets the display start location of the alert.
This method will only gurantee no overlap if the location is
SwingConstants.SOUTH_EAST
,
SwingConstants.SOUTH_WEST
, SwingConstants.NORTH_EAST
or
SwingConstants.NORTH_WEST
.
If the whole screen is coverred with alert (which is very rare case), this method will always return at the
default location just like when AlertGroup
is not in use at all.
- Parameters:
alert
- the alert.screenDim
- the screen dimension or the owner's dimension if displaying within the owner boundry.size
- the size of the alert.location
- the location relative to screen.gap
- the gap between two alerts (horizontally or vertically)
- Returns:
- the location of the alert where should be displayed which won't cause any overlap.