public interface TopLevelContainer
The contract shared by the two things that can sit at the root of a Codename One
component hierarchy: Form, which fills the application’s main surface, and
Window, which is a separate native operating system window on the desktop.
Code that needs to work against “whatever top level I happen to be in” should
resolve it with Component#getTopLevelContainer() and talk to it through this
interface, rather than through Component#getComponentForm(). The latter keeps
its original meaning and returns null for a component hosted inside a Window.
This interface is implemented by Form and Window only. It is not intended to
be implemented outside the framework – several of its collaborators are package
private – and it may gain members in any release.
Members that belong to a Component or a Container are deliberately absent –
reach them through #asContainer() instead. So are the parts of Form that model
mobile navigation, such as form transitions, the back command and the menu bar;
those have no meaning for a desktop window.
Methods
Method details
addComponentAwaitingRelease
public abstract <C extends Component> void addComponentAwaitingRelease(C c)Returns this top level as a Container.
A Java interface cannot extend a class, so without this a TopLevelContainer
reference could not be handed to anything expecting a Component.
Parameters
cC- the component awaiting a release
Returns
Container
Records a component that is waiting for a pointer release, so the top level can
release it if the gesture ends somewhere else.removeComponentAwaitingRelease
public abstract <C extends Component> void removeComponentAwaitingRelease(C c)Parameters
cC- the component to stop tracking
clearComponentsAwaitingRelease
public abstract void clearComponentsAwaitingRelease()asContainer
public abstract Container asContainer()getContentPane
public abstract Container getContentPane()Returns
getLayeredPane
public abstract Container getLayeredPane()Returns
getLayeredPane
public abstract Container getLayeredPane(Class c, boolean top)Parameters
cClass- the class owning the layer
topboolean- true to place the layer above the existing layers
Returns
getLayeredPane
public abstract Container getLayeredPane(Class c, int zIndex)Parameters
cClass- the class owning the layer
zIndexint- the depth at which the layer should sit
Returns
getFormLayeredPane
public abstract Container getFormLayeredPane(Class c, boolean top)Parameters
cClass- the class owning the layer
topboolean- true to place the layer above the existing layers
Returns
getGlassPane
public abstract Painter getGlassPane()Returns
setGlassPane
public abstract void setGlassPane(Painter glassPane)Parameters
glassPanePainter- the painter to install, or null to remove the current one
getTitle
public abstract String getTitle()Returns
setTitle
public abstract void setTitle(String title)Parameters
titleString- the title to display
addCommand
public abstract void addCommand(Command cmd)Parameters
cmdCommand- the command to add
removeCommand
public abstract void removeCommand(Command cmd)Parameters
cmdCommand- the command to remove
removeAllCommands
public abstract void removeAllCommands()getCommandCount
public abstract int getCommandCount()Returns
getCommand
public abstract Command getCommand(int index)Parameters
indexint- the offset of the command
Returns
addCommandListener
public abstract void addCommandListener(ActionListener l)Parameters
lActionListener- the listener to add
removeCommandListener
public abstract void removeCommandListener(ActionListener l)Parameters
lActionListener- the listener to remove
getAnimationManager
public abstract AnimationManager getAnimationManager()Returns
registerAnimated
public abstract void registerAnimated(Animation cmp)Parameters
cmpAnimation- the animation to register
deregisterAnimated
public abstract void deregisterAnimated(Animation cmp)Parameters
cmpAnimation- the animation to remove
grabAnimationLock
public abstract boolean grabAnimationLock()Returns
releaseAnimationLock
public abstract void releaseAnimationLock()getFocused
public abstract Component getFocused()Returns
setFocused
public abstract void setFocused(Component focused)Parameters
focusedComponent- the component that should take focus
isCyclicFocus
public abstract boolean isCyclicFocus()Returns
setCyclicFocus
public abstract void setCyclicFocus(boolean cyclicFocus)Parameters
cyclicFocusboolean- true to make focus cyclic
isSingleFocusMode
public abstract boolean isSingleFocusMode()Returns
getTabIterator
public abstract Form.TabIterator getTabIterator(Component start)Parameters
startComponent- the component to start from
Returns
scrollComponentToVisible
public abstract void scrollComponentToVisible(Component c)Parameters
cComponent- the component to reveal
addKeyListener
public abstract void addKeyListener(int keyCode, ActionListener listener)Parameters
keyCodeint- the key code to bind
listenerActionListener- the listener invoked for that key
removeKeyListener
public abstract void removeKeyListener(int keyCode, ActionListener listener)Parameters
keyCodeint- the bound key code
listenerActionListener- the listener to remove
isEditing
public abstract boolean isEditing()Returns
stopEditing
public abstract void stopEditing(Runnable onFinish)Parameters
onFinishRunnable- invoked once editing has stopped
findCurrentlyEditingComponent
public abstract Component findCurrentlyEditingComponent()Returns
getCurrentInputDevice
public abstract VirtualInputDevice getCurrentInputDevice()Returns
setCurrentInputDevice
public abstract void setCurrentInputDevice(VirtualInputDevice device)
throws ExceptionParameters
deviceVirtualInputDevice- the device to open, or null to close the current one
Throws
Exception- if the previously open device failed to close
getUIManager
public abstract UIManager getUIManager()Returns
setUIManager
public abstract void setUIManager(UIManager uiManager)Parameters
uiManagerUIManager- the UI manager to use
getTintColor
public abstract int getTintColor()Returns
setTintColor
public abstract void setTintColor(int tintColor)Parameters
tintColorint- the tint colour, alpha in the high byte
isTopLevelShowing
public abstract boolean isTopLevelShowing()Whether this top level is the one the user can currently see.
Display#getCurrent() only ever names a Form, so comparing against it
answers false for every window – which is why anything that gated on it
stopped working the moment it was put in one. A window is on screen in its own
right, and answers for itself.
Returns
getSafeArea
public abstract Rectangle getSafeArea()Returns
getInvisibleAreaUnderVKB
public abstract int getInvisibleAreaUnderVKB()Returns
getDragRegionStatus
public abstract int getDragRegionStatus(int x, int y)Parameters
xint- the x coordinate
yint- the y coordinate
Returns
isEnableCursors
public abstract boolean isEnableCursors()Returns
setEnableCursors
public abstract void setEnableCursors(boolean e)Parameters
eboolean- true to enable cursors
getTextSelection
public abstract TextSelection getTextSelection()Returns
show
public abstract void show()addShowListener
public abstract void addShowListener(ActionListener l)Parameters
lActionListener- the listener to add
removeShowListener
public abstract void removeShowListener(ActionListener l)Parameters
lActionListener- the listener to remove
addSizeChangedListener
public abstract void addSizeChangedListener(ActionListener l)Parameters
lActionListener- the listener to add
removeSizeChangedListener
public abstract void removeSizeChangedListener(ActionListener l)Parameters
lActionListener- the listener to remove
dispatchCommand
public abstract void dispatchCommand(Command cmd, ActionEvent ev)Command triggers it without knowing whether it
lives in a Form or a Window.Parameters
cmdCommand- the command to dispatch
evActionEvent- the event to dispatch