public class Desktop extends Displayable implements Renderable
Display
.Display
, and that relationship cannot be modified.Display
.
A desktop can contains several Panel
instances.
These panels are stored in a list. The order of the list defines the front-to-back stacking order of the panels
within the desktop. The first panel in the list is at the back of the stacking order.
Display
,
Panel
Constructor and Description |
---|
Desktop()
Creates a new desktop on the default display.
Identical to new Desktop( . |
Desktop(Display display)
Creates a new desktop on the specified display.
|
Modifier and Type | Method and Description |
---|---|
void |
becomeCurrent() |
Panel |
getActivePanel()
Gets this desktop's active panel.
|
EventHandler |
getController() |
EventHandler |
getEventHandler()
Gets the event handler.
|
int |
getHeight()
Returns the height of this desktop: it is equal to the height of its associated display.
|
Panel[] |
getPanels()
Gets the list of the panels being shown on this desktop.
|
int |
getWidth()
Returns the width of this desktop: it is equal to the width of its associated display.
|
int |
getX()
Returns the x coordinate of this desktop, which is always 0.
|
int |
getY()
Returns the y coordinate of this desktop, which is always 0.
|
boolean |
handleEvent(int event)
Called by the system if no widget nor panel in the focused hierarchy has consumed the event.
|
void |
hideNotify()
The desktop is hidden from its display.
|
boolean |
isAccessible(Panel panel)
Checks whether or not a panel is accessible to the user.
|
void |
paint(GraphicsContext g) |
Panel |
panelAt(int x,
int y)
Gets the panel at the specified position.
|
void |
render(GraphicsContext g)
Renders the renderable on the given graphics context.
|
void |
repaint(int x,
int y,
int width,
int height)
Requests a repaint of a zone of this desktop.
|
void |
revalidate()
Lays out all the hierarchy of this desktop.
|
void |
setActivePanel(Panel panel)
Sets the specified panel as the active one on this desktop.
|
void |
setEventHandler(EventHandler eventHandler)
Sets the event handler.
|
void |
showNotify()
The desktop is visible on its display.
|
void |
validate()
Lays out all the hierarchy of this desktop.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isShown, repaint
public Desktop()
new Desktop(Display#getDefaultDisplay()
)
.public Desktop(@NonNull Display display) throws java.lang.NullPointerException
display
- the display for which the desktop is created.java.lang.NullPointerException
- if display
is null
.public int getX()
getX
in interface Renderable
public int getY()
getY
in interface Renderable
public int getWidth()
getWidth
in interface Renderable
public int getHeight()
getHeight
in interface Renderable
public void repaint(int x, int y, int width, int height)
This method returns immediately, the repaint of the desktop is performed asynchronously.
If the desktop 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(@NonNull GraphicsContext g)
Renderable
render
in interface Renderable
g
- the graphics context to be used to draw the renderable.@Nullable public Panel getActivePanel()
null
if none.public void setActivePanel(@NonNull Panel panel) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
panel
- the panel to set activejava.lang.NullPointerException
- if the specified panel is null.java.lang.IllegalArgumentException
- if the specified panel is not on this desktop.getActivePanel()
@NonNull public Panel[] getPanels()
A panel is added to this list when a panel is shown on this desktop and removed when a panel is hidden from this desktop.
Panel.showFullScreen(Desktop)
,
Panel.showAdjustingToChild(Desktop)
,
Panel.showUsingBounds(Desktop)
,
Panel.hide()
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 it is not shown.
validate()
public void validate()
Panel.validate()
public void showNotify()
Notifies its children panels that they are shown.
Ask for a revalidation of the entire desktop.
showNotify
in interface Renderable
revalidate()
public void hideNotify()
Notifies its children panels that they are hidden.
hideNotify
in interface Renderable
public void becomeCurrent()
@NonNull public EventHandler getController()
public void setEventHandler(@Nullable EventHandler eventHandler)
Renderable
setEventHandler
in interface Renderable
eventHandler
- the event handler to set.Renderable.handleEvent(int)
@Nullable public EventHandler getEventHandler()
Renderable
getEventHandler
in interface Renderable
Renderable.handleEvent(int)
public boolean handleEvent(int event)
handleEvent
in interface Renderable
event
- the event to handletrue
if the desktop has consumed the event, false
otherwisepublic final void paint(GraphicsContext g)
@Nullable public Panel panelAt(int x, int y)
x
- the x coordinate to search at.y
- the y coordinate to search at.null
if none.public boolean isAccessible(@NonNull Panel panel)
A panel is accessible if:
panel
- the panel to check.true
if the panel is accessible, false
otherwise.