public class Panel extends java.lang.Object implements Renderable
Constructor and Description |
---|
Panel()
Creates a new panel.
|
Modifier and Type | Method and Description |
---|---|
void |
becameActive()
Notifies the panel that it is now the active panel of its desktop.
|
void |
becameInactive()
Notifies the panel that it is no longer the active panel of its desktop.
|
boolean |
contains(int x,
int y)
Returns
true if the (x,y) position is in the panel's bounds, false otherwise.The location is considered here as a relative location to the desktop. |
Desktop |
getDesktop()
Gets the desktop on which the panel is shown.
|
ej.microui.util.EventHandler |
getEventHandler()
Gets the event handler.
|
Widget |
getFocus()
Gets the widget that is the focus owner of this panel.
|
int |
getHeight()
Gets the height of this renderable.
|
int |
getPreferredHeight()
Returns the preferred height of the panel.
|
int |
getPreferredWidth()
Returns the preferred width of the panel.
|
Widget |
getWidget()
Gets the widget attached to this panel.
|
Widget |
getWidgetAt(int x,
int y)
Returns the child widget at the specified location.
|
int |
getWidth()
Gets the width of this renderable.
|
int |
getX()
Gets the x coordinate of this renderable, relative to its parent.
|
int |
getY()
Gets the y coordinate of this renderable, relative to its parent.
|
boolean |
handleEvent(int event)
Called by the system if this is the active panel and if no widget in the hierarchy of the focused widget has
consumed the event.
|
void |
hide()
Requests the panel be hidden.
The panel is invalidated. The panel is removed from the list of panels known by the desktop. |
void |
hideNotify()
This method is called as soon as the renderable is hidden.
|
void |
invalidate()
Declares that this panel needs to be laid out.
|
boolean |
isActive()
Gets whether or not the panel is the active one on its desktop.
|
boolean |
isPacked()
Gets whether this panel is packed or not.
|
boolean |
isShown()
Gets whether or not the panel is shown on a shown desktop.
|
boolean |
isTransparent()
Gets whether this panel is transparent or not.
|
boolean |
isValid()
Gets whether this panel is valid.
|
void |
render(ej.microui.display.GraphicsContext g)
Renders the renderable on the given graphics context.
|
void |
repaint()
Requests a repaint of this entire panel.
|
void |
repaint(int x,
int y,
int width,
int height)
Requests a repaint of a zone of this panel.
|
void |
revalidate()
Lays out all the hierarchy of this panel.
|
void |
setBounds(int x,
int y,
int width,
int height)
Set the bounds of this panel.
|
void |
setEventHandler(ej.microui.util.EventHandler eventHandler)
Sets the event handler.
|
void |
setFocus(Widget widget)
Sets the specified widget as the current focus owner of this panel.
|
void |
setLocation(int x,
int y)
Set the location of this panel.
|
void |
setPacked(boolean packed)
Sets this panel as packed or not.
This property is used when the panel is validated: if it is packed (specified boolean is true ), the
panel is resized to the preferred size of its widgets, otherwise its widgets fill its size. |
void |
setPreferredSize(int preferredWidth,
int preferredHeight)
Sets the preferred size of the panel.
|
void |
setSize(int width,
int height)
Set the size of this panel.
|
void |
setWidget(Widget widget)
Attach the specified widget to this panel.
|
void |
show(Desktop desktop)
Requests the panel to be shown on the specified desktop.
|
void |
show(Desktop desktop,
boolean fill)
Requests the panel to be shown on the specified desktop.
|
void |
showNotify()
This method is called as soon as the renderable is visible.
|
void |
validate()
Lays out all the hierarchy of this panel.
|
void |
validate(int widthHint,
int heightHint)
Lays out all the hierarchy of this panel.
After this call the preferred size will have been established. |
public Panel()
By default:
0
,public void setWidget(Widget widget) throws java.lang.IllegalArgumentException
If there is already a widget on this panel, the former is detached from the latter.
If the specified widget is null
, the panel does not hold a widget anymore.
The panel is also ask to be revalidated if shown.
widget
- the widget to set.java.lang.IllegalArgumentException
- if the specified widget or one of its children is already connected to a Panel
.revalidate()
public Widget getWidget()
null
public void setLocation(int x, int y)
Equivalent to calling setBounds(int, int, int, int)
passing the given location and the current size.
x
- the x coordinate to sety
- the y coordinate to setpublic void setSize(int width, int height)
Equivalent to calling setBounds(int, int, int, int)
passing the current location and the given size.
width
- the width to setheight
- the height to setpublic void setBounds(int x, int y, int width, int height)
x
- the x coordinate to sety
- the y coordinate to setwidth
- the width to setheight
- the height to setpublic int getPreferredWidth()
isValid()
is
true
or if setPreferredSize(int, int)
has been called explicitly.public int getPreferredHeight()
isValid()
is
true
or if setPreferredSize(int, int)
has been called explicitly.public void setPreferredSize(int preferredWidth, int preferredHeight)
preferredWidth
- the width to setpreferredHeight
- the height to setpublic int getX()
Renderable
getX
in interface Renderable
public int getY()
Renderable
getY
in interface Renderable
public int getWidth()
Renderable
getWidth
in interface Renderable
public int getHeight()
Renderable
getHeight
in interface Renderable
public void show(Desktop desktop) throws java.lang.NullPointerException
Identical to calling show(Desktop, boolean)
without filling the desktop.
desktop
- the desktopjava.lang.NullPointerException
- if desktop
is null
.show(Desktop, boolean)
,
hide()
,
isShown()
,
revalidate()
public void show(Desktop desktop, boolean fill) throws java.lang.NullPointerException
If fill
is true
, it is fitted to desktop size and it will be declared as not be packed.
If fill
is false
and no size has been set, it will be declared as packed.
If the desktop is shown, the panel is automatically validated.
The panel is added to the list of panels known by the desktop.
Special cases:
desktop
- the desktopfill
- true
to fit the panel to the desktop size, false
otherwisejava.lang.NullPointerException
- if desktop
is null
.hide()
,
isShown()
,
revalidate()
public void showNotify()
Notifies its child widget that it is shown.
showNotify
in interface Renderable
public void hideNotify()
Notifies its child widget that it is hidden.
hideNotify
in interface Renderable
public void hide()
show(Desktop)
,
isShown()
public boolean isShown()
isShown
in interface Renderable
true
if the panel is shown, false
otherwise.getDesktop()
,
Displayable.isShown()
public boolean isActive()
false
.true
if the panel is the active one, false
otherwise.isShown()
public void becameActive()
public void becameInactive()
public Desktop getDesktop()
null
if the panel is not shown.null
.isShown()
public void repaint()
If the panel is not shown, nothing is done.
repaint
in interface Renderable
public void repaint(int x, int y, int width, int height)
If the panel is not shown, nothing is done.
repaint
in interface Renderable
x
- the relative x coordinate of the area to repaint.y
- the relative y coordinate of the area to repaint.width
- the width of the area to repaint.height
- the height of the area to repaint.public void render(ej.microui.display.GraphicsContext g)
Renderable
render
in interface Renderable
g
- the graphics context to be used to draw the renderable.public boolean isTransparent()
By default, a panel is transparent.
A transparent panel means that it will not repaint ALL the rectangular zone defined by its bounds. Then each time
it needs to be repainted, its parent (recursively if also transparent) will be repainted within the bounds of the
panel.
Each time a non-transparent panel needs to be repainted, it is the only one to be repainted.
true
if this panel is transparent, false
otherwise.contains(int, int)
public boolean contains(int x, int y)
true
if the (x,y) position is in the panel's bounds, false
otherwise.x
- x coordinatey
- y coordinatetrue
if the (x,y) position is in the panel bounds, false
otherwise.isTransparent()
public Widget getWidgetAt(int x, int y)
contains(x, y)
,
null
is returned. The location is considered here as a relative location to the desktop.x
- x coordinatey
- y coordinatenull
if no widget is found in this panel hierarchy.Widget.getWidgetAt(int, int)
public void setFocus(Widget widget) throws java.lang.IllegalArgumentException
If the widget is not enabled, nothing is done.
If the widget already own the focus, nothing is done.
Throws an IllegalArgumentException
if the specified widget is not in the panel.
widget
- the widget to focus.java.lang.IllegalArgumentException
- if the specified widget is not in the panel.public Widget getFocus()
public void setPacked(boolean packed)
Sets this panel as packed or not.
This property is used when the panel is validated: if it is packed (specified boolean is true
), the
panel is resized to the preferred size of its widgets, otherwise its widgets fill its size.
packed
- true
to pack the panel, false
otherwiserevalidate()
,
setSize(int, int)
public boolean isPacked()
Gets whether this panel is packed or not.
true
if this panel is packed, false
otherwise.public void invalidate()
Declares that this panel needs to be laid out.
revalidate()
,
validate()
public boolean isValid()
Gets whether this panel is valid.
A panel is valid if its contents are correctly laid out.
true
if this panel is valid, false
otherwiseinvalidate()
,
validate()
public void revalidate()
It performs the method validate()
asynchronously. Therefore this method does not block until the
validation of the hierarchy is done.
Nothing is done if the panel is already valid.
The panel is not validated if it is not shown or if its desktop is not shown.
invalidate()
public void validate()
Nothing is done if the panel is already valid.
The panel is repainted if it is shown on a desktop.
If the panel is declared as packed, it is resized to the preferred size of its widgets, otherwise its widgets fill its size.
isPacked()
,
isValid()
public void validate(int widthHint, int heightHint)
MWT.NONE
if there is no constraint.public void setEventHandler(ej.microui.util.EventHandler eventHandler)
Renderable
setEventHandler
in interface Renderable
eventHandler
- the event handler to set.Renderable.handleEvent(int)
public ej.microui.util.EventHandler getEventHandler()
Renderable
getEventHandler
in interface Renderable
Renderable.handleEvent(int)
public boolean handleEvent(int event)
Command.UP
, Command.DOWN
, Command.LEFT
, and
Command.RIGHT
commands to manage navigation.handleEvent
in interface Renderable
event
- the event to handletrue
if the panel has consumed the event, false
otherwise