|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbuoy.event.EventSource
buoy.widget.Widget
buoy.widget.WidgetContainer
buoy.widget.OverlayContainer
public class OverlayContainer
OverlayContainer is a WidgetContainer which overlays its children on top of each other. Every child Widget is sized to fill the entire container, and the preferred size of the container is equal to the largest preferred size of any of its children.
OverlayContainers are generally used to switch between several different Widgets which all appear in the
same position. When used this way, only one of the Widgets will be visible at any time. The
setVisibleChild()
method provides an easy way to
switch between the child Widgets by showing one and hiding all the others.
Another use of OverlayContainer is to place a partially transparent Widget in front of
another one. This allows an "overlay" to be displayed at a particular position, independent of the
positions of other Widgets in the window. An OverlayContainer can also be used to block mouse events
from reaching a Widget. Mouse events are always delivered to the topmost visible Widget that has requested
to receive them. Suppose that mainWidget
is a Widget (possibly a WidgetContainer with
many children). The following code will block all mouse events from reaching it and its children:
CustomWidget blocker = new CustomWidget(); blocker.setOpaque(false); blocker.addEventLink(WidgetMouseEvent.class, new Object() { void processEvent() { // Ignore the event. } }); OverlayContainer overlay = new OverlayContainer(); overlay.add(mainWidget); overlay.add(blocker);
You can then turn event blocking on or off by calling blocker.setVisible(true)
or
blocker.setVisible(false)
. Note that we have added an event link to blocker
which listens for mouse events. If you do not do this, it will ignore mouse events and let them pass
through to the Widget underneath.
In addition to the event types generated by all Widgets, OverlayContainers generate the following event types:
Constructor Summary | |
---|---|
OverlayContainer()
Create a new OverlayContainer. |
Method Summary | |
---|---|
void |
add(Widget widget)
Add a Widget to this container. |
void |
add(Widget widget,
int index)
Add a Widget to this container. |
Widget |
getChild(int i)
Get the i'th child of this container. |
int |
getChildCount()
Get the number of children in this container. |
int |
getChildIndex(Widget widget)
Get the index of a particular Widget. |
java.util.Collection<Widget> |
getChildren()
Get a Collection containing all child Widgets of this container. |
javax.swing.JPanel |
getComponent()
Get the java.awt.Component corresponding to this Widget. |
java.awt.Dimension |
getMinimumSize()
Get the smallest size at which this Widget can reasonably be drawn. |
java.awt.Dimension |
getPreferredSize()
Get the preferred size at which this Widget will look best. |
void |
layoutChildren()
Layout the child Widgets. |
void |
remove(Widget widget)
Remove a child Widget from this container. |
void |
removeAll()
Remove all child Widgets from this container. |
void |
setVisibleChild(int i)
Set the i'th child Widget to be visible, and all others to be not visible. |
void |
setVisibleChild(Widget child)
Set a particular child Widget to be visible, and all others to be not visible. |
Methods inherited from class buoy.widget.WidgetContainer |
---|
isOpaque, setOpaque |
Methods inherited from class buoy.widget.Widget |
---|
addEventLink, dispatchEvent, getBackground, getBounds, getCursor, getFont, getMaximumSize, getName, getParent, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible |
Methods inherited from class buoy.event.EventSource |
---|
addEventLink, addEventLink, removeEventLink |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OverlayContainer()
Method Detail |
---|
public javax.swing.JPanel getComponent()
Widget
getComponent
in class Widget
public int getChildCount()
getChildCount
in class WidgetContainer
public Widget getChild(int i)
public java.util.Collection<Widget> getChildren()
getChildren
in class WidgetContainer
public int getChildIndex(Widget widget)
widget
- the Widget to locate
public void layoutChildren()
layoutChildren
in class WidgetContainer
public void add(Widget widget, int index)
widget
- the Widget to addindex
- the index of the Widget within the container. Widgets with lower indices are displayed
in front of ones with higher indices.public void add(Widget widget)
widget
- the Widget to addpublic void remove(Widget widget)
remove
in class WidgetContainer
widget
- the Widget to removepublic void removeAll()
removeAll
in class WidgetContainer
public void setVisibleChild(int i)
public void setVisibleChild(Widget child)
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class Widget
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class Widget
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |