Class Toolbar
- All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>
Toolbar replaces the default title area with a powerful abstraction that allows functionality ranging from side menus (hamburger) to title animations and any arbitrary component type. Toolbar allows customizing the Form title with different commands on the title area, within the side menu or the overflow menu.
The Toolbar allows placing components in one of 4 positions as illustrated by the sample below:
Toolbar.setGlobalToolbar(true);
Form hi = new Form("Toolbar", new BoxLayout(BoxLayout.Y_AXIS));
Style s = UIManager.getInstance().getComponentStyle("TitleCommand");
FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_WARNING, s);
hi.getToolbar().addCommandToLeftBar("Left", icon, (e) -> Log.p("Clicked"));
hi.getToolbar().addCommandToRightBar("Right", icon, (e) -> Log.p("Clicked"));
hi.getToolbar().addCommandToOverflowMenu("Overflow", icon, (e) -> Log.p("Clicked"));
hi.getToolbar().addCommandToSideMenu("Sidemenu", icon, (e) -> Log.p("Clicked"));
hi.show();
Toolbar supports a search mode that implicitly replaces the title
with a search field/magnifying glass effect. The code below demonstrates
searching thru the contacts using this API:
Image duke = null;
try {
duke = Image.createImage("/duke.png");
} catch(IOException err) {
Log.e(err);
}
int fiveMM = Display.getInstance().convertToPixels(5);
final Image finalDuke = duke.scaledWidth(fiveMM);
Toolbar.setGlobalToolbar(true);
Form hi = new Form("Search", BoxLayout.y());
hi.add(new InfiniteProgress());
Display.getInstance().scheduleBackgroundTask(()-> {
// this will take a while...
Contact[] cnts = Display.getInstance().getAllContacts(true, true, true, true, false, false);
Display.getInstance().callSerially(() -> {
hi.removeAll();
for(Contact c : cnts) {
MultiButton m = new MultiButton();
m.setTextLine1(c.getDisplayName());
m.setTextLine2(c.getPrimaryPhoneNumber());
Image pic = c.getPhoto();
if(pic != null) {
m.setIcon(fill(pic, finalDuke.getWidth(), finalDuke.getHeight()));
} else {
m.setIcon(finalDuke);
}
hi.add(m);
}
hi.revalidate();
});
});
hi.getToolbar().addSearchCommand(e -> {
String text = (String)e.getSource();
if(text == null || text.length() == 0) {
// clear search
for(Component cmp : hi.getContentPane()) {
cmp.setHidden(false);
cmp.setVisible(true);
}
hi.getContentPane().animateLayout(150);
} else {
text = text.toLowerCase();
for(Component cmp : hi.getContentPane()) {
MultiButton mb = (MultiButton)cmp;
String line1 = mb.getTextLine1();
String line2 = mb.getTextLine2();
boolean show = line1 != null && line1.toLowerCase().indexOf(text) > -1 ||
line2 != null && line2.toLowerCase().indexOf(text) > -1;
mb.setHidden(!show);
mb.setVisible(show);
}
hi.getContentPane().animateLayout(150);
}
}, 4);
hi.show();
The following code also demonstrates search with a more custom UX where the
title area was replaced dynamically. This code predated the builtin search
support above. Notice that the TextField and its hint are styled to
look like the title.
Toolbar.setGlobalToolbar(true);
Style s = UIManager.getInstance().getComponentStyle("Title");
Form hi = new Form("Toolbar", BoxLayout.y());
TextField searchField = new TextField("", "Toolbar Search");
searchField.getHintLabel().setUIID("Title");
searchField.setUIID("Title");
searchField.getAllStyles().setAlignment(Component.LEFT);
hi.getToolbar().setTitleComponent(searchField);
FontImage searchIcon = FontImage.createMaterial(FontImage.MATERIAL_SEARCH, s);
hi.getToolbar().addCommandToRightBar("", searchIcon, e -> searchField.startEditingAsync());
hi.addAll(new Label("A Game of Thrones"), new Label("A Clash Of Kings"), new Label("A Storm Of Swords"));
searchField.addDataChangedListener((type, index) -> {
String text = searchField.getText().toLowerCase();
for (Component cmp : hi.getContentPane()) {
Label l = (Label) cmp;
boolean show = text.length() == 0 || l.getText().toLowerCase().indexOf(text) > -1;
cmp.setHidden(!show);
cmp.setVisible(show);
}
hi.getContentPane().animateLayout(250);
});
hi.show();
This sample code show off title animations that allow a title to change (and potentially shrink) as the user scrolls down the UI. The 3 frames below show a step by step process in the change.
Toolbar.setGlobalToolbar(true);
Form hi = new Form("Toolbar", new BoxLayout(BoxLayout.Y_AXIS));
EncodedImage placeholder = EncodedImage.createFromImage(Image.createImage(hi.getWidth(), hi.getWidth() / 5, 0xffff0000), true);
URLImage background = URLImage.createToStorage(placeholder, "400px-AGameOfThrones.jpg",
"http://awoiaf.westeros.org/images/thumb/9/93/AGameOfThrones.jpg/400px-AGameOfThrones.jpg");
background.fetch();
Style stitle = hi.getToolbar().getTitleComponent().getUnselectedStyle();
stitle.setBgImage(background);
stitle.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL);
stitle.setPaddingUnit(Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS, Style.UNIT_TYPE_DIPS);
stitle.setPaddingTop(15);
SpanButton credit = new SpanButton("This excerpt is from A Wiki Of Ice And Fire. Please check it out by clicking here!");
credit.addActionListener((e) -> Display.getInstance().execute("http://awoiaf.westeros.org/index.php/A_Game_of_Thrones"));
hi.add(new SpanLabel("A Game of Thrones is the first of seven planned novels in A Song of Ice and Fire, an epic fantasy series by American author George R. R. Martin. It was first published on 6 August 1996. The novel was nominated for the 1998 Nebula Award and the 1997 World Fantasy Award,[1] and won the 1997 Locus Award.[2] The novella Blood of the Dragon, comprising the Daenerys Targaryen chapters from the novel, won the 1997 Hugo Award for Best Novella. ")).
add(new Label("Plot introduction", "Heading")).
add(new SpanLabel("A Game of Thrones is set in the Seven Kingdoms of Westeros, a land reminiscent of Medieval Europe. In Westeros the seasons last for years, sometimes decades, at a time.\n\n" +
"Fifteen years prior to the novel, the Seven Kingdoms were torn apart by a civil war, known alternately as \"Robert's Rebellion\" and the \"War of the Usurper.\" Prince Rhaegar Targaryen kidnapped Lyanna Stark, arousing the ire of her family and of her betrothed, Lord Robert Baratheon (the war's titular rebel). The Mad King, Aerys II Targaryen, had Lyanna's father and eldest brother executed when they demanded her safe return. Her second brother, Eddard, joined his boyhood friend Robert Baratheon and Jon Arryn, with whom they had been fostered as children, in declaring war against the ruling Targaryen dynasty, securing the allegiances of House Tully and House Arryn through a network of dynastic marriages (Lord Eddard to Catelyn Tully and Lord Arryn to Lysa Tully). The powerful House Tyrell continued to support the King, but House Lannister and House Martell both stalled due to insults against their houses by the Targaryens. The civil war climaxed with the Battle of the Trident, when Prince Rhaegar was killed in battle by Robert Baratheon. The Lannisters finally agreed to support King Aerys, but then brutally... ")).
add(credit);
ComponentAnimation title = hi.getToolbar().getTitleComponent().createStyleAnimation("Title", 200);
hi.getAnimationManager().onTitleScrollAnimation(title);
hi.show();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe behavior of the back command in the title -
Field Summary
Fields inherited from class Component
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSORModifier and TypeFieldDescriptionstatic final intAlignment to the baseline constraintstatic final intBox-orientation constant used to specify the bottom of a box.static final intBaseline resize behavior constant used to properly align components.static final intBaseline resize behavior constant used to properly align components.static final intBaseline resize behavior constant used to properly align components.static final intBaseline resize behavior constant used to properly align components.static final intIndicates a Component center alignmentstatic final intThe crosshair cursor type.static final intThe default cursorstatic final intUsed by getDragRegionStatus to indicate immediate dragabilitystatic final intUsed by getDragRegionStatus to indicate immediate dragabilitystatic final intUsed by getDragRegionStatus to indicate immediate dragabilitystatic final intUsed by getDragRegionStatus to indicate likely dragabilitystatic final intUsed by getDragRegionStatus to indicate likely dragabilitystatic final intUsed by getDragRegionStatus to indicate likely dragabilitystatic final intUsed by getDragRegionStatus to indicate no dragabilitystatic final intUsed by getDragRegionStatus to indicate limited dragabilitystatic final intUsed by getDragRegionStatus to indicate limited dragabilitystatic final intUsed by getDragRegionStatus to indicate limited dragabilitystatic final intThe east-resize cursor type.static final intThe hand cursor type.static final intBox-orientation constant used to specify the left side of a box.static final intThe move cursor type.static final intThe north-resize cursor type.static final intThe north-east-resize cursor type.static final intThe north-west-resize cursor type.static final intBox-orientation constant used to specify the right side of a box.static final intThe south-resize cursor type.static final intThe south-east-resize cursor type.static final intThe south-west-resize cursor type.static final intThe text cursor type.static final intBox-orientation constant used to specify the top of a box.static final intThe west-resize cursor type.static final intThe wait cursor type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a Command to the TitleArea on the left side.addCommandToLeftBar(String name, Image icon, ActionListener ev) Adds a Command to the TitleArea on the left side.voidAdds a Command to the left side navigation menuaddCommandToLeftSideMenu(String name, Image icon, ActionListener ev) Adds a Command to the left side navigation menuvoidAdds a Command to the overflow menuaddCommandToOverflowMenu(String name, Image icon, ActionListener ev) Adds a Command to the overflow menuvoidAdds a Command to the TitleArea on the right side.addCommandToRightBar(String name, Image icon, ActionListener ev) Adds a Command to the TitleArea on the right side.voidAdds a Command to the right side navigation menu (it requires a permanent sidemenu or an onTop mode sidemenu, otherwise it does nothing).addCommandToRightSideMenu(String name, Image icon, ActionListener ev) Adds a Command to the right side navigation menu (it requires a permanent sidemenu or an onTop mode sidemenu, otherwise it does nothing)voidAdds a Command to the left or right side navigation menu according to the state of RTL.addCommandToSideMenu(String name, Image icon, ActionListener ev) Adds a Command to the left or right side navigation menu according to the state of RTL.voidAdds a Component to the left side navigation menu.voidaddComponentToLeftSideMenu(Component cmp, Command cmd) Adds a Component to the left side navigation menu.protected voidaddComponentToLeftSideMenu(Container menu, Component cmp) This method responsible to add a Component to the left side navigation panel.voidAdds a Component to the right side navigation menu (it requires a permanent sidemenu or an onTop sidemenu, otherwise it does nothing).voidaddComponentToRightSideMenu(Component cmp, Command cmd) Adds a Component to the right side navigation menu (it requires a permanent sidemenu or an onTop sidemenu, otherwise it does nothing).protected voidaddComponentToRightSideMenu(Container menu, Component cmp) This method responsible to add a Component to the right side navigation panel.voidAdds a Component to the left or right side navigation menu, according to the state of RTL.voidaddComponentToSideMenu(Component cmp, Command cmd) Adds a Component to the left or right side navigation menu, according to the state of RTL.protected voidaddComponentToSideMenu(Container menu, Component cmp) This method is responsible to add a Component to the left or right side navigation panel according to the state of RTL.addMaterialCommandToLeftBar(String name, char icon, float size, ActionListener ev) Adds a Command to the TitleArea on the left side with a material design icon referencecom.codename1.ui.FontImage.addMaterialCommandToLeftBar(String name, char icon, ActionListener ev) Adds a Command to the TitleArea on the left side with a material design icon referencecom.codename1.ui.FontImage.addMaterialCommandToLeftSideMenu(String name, char icon, float size, ActionListener ev) Adds a Command to the left side navigation menu with a material design icon referencecom.codename1.ui.FontImage.addMaterialCommandToLeftSideMenu(String name, char icon, ActionListener ev) Adds a Command to the left side navigation menu with a material design icon referencecom.codename1.ui.FontImage.addMaterialCommandToOverflowMenu(String name, char icon, float size, ActionListener ev) Adds a Command to the overflow menu with a material design icon referencecom.codename1.ui.FontImage.addMaterialCommandToOverflowMenu(String name, char icon, ActionListener ev) Adds a Command to the overflow menu with a material design icon referencecom.codename1.ui.FontImage.addMaterialCommandToRightBar(String name, char icon, float size, ActionListener ev) Adds a Command to the TitleArea on the right side with a material design icon referencecom.codename1.ui.FontImage.addMaterialCommandToRightBar(String name, char icon, ActionListener ev) Adds a Command to the TitleArea on the right side with a material design icon referencecom.codename1.ui.FontImage.addMaterialCommandToRightSideMenu(String name, char icon, float size, ActionListener ev) Adds a Command to the right side navigation menu with a material design icon referencecom.codename1.ui.FontImage(it requires a permanent sidemenu or an onTop mode sidemenu, otherwise it does nothing).addMaterialCommandToRightSideMenu(String name, char icon, ActionListener ev) Adds a Command to the right side navigation menu with a material design icon referencecom.codename1.ui.FontImage(it requires a permanent sidemenu or an onTop mode sidemenu, otherwise it does nothing).addMaterialCommandToSideMenu(String name, char icon, float size, ActionListener ev) Adds a Command to the left or right side navigation menu (according to the state of RTL) with a material design icon referencecom.codename1.ui.FontImage.addMaterialCommandToSideMenu(String name, char icon, ActionListener ev) Adds a Command to the left or right side navigation menu (according to the state of RTL) with a material design icon referencecom.codename1.ui.FontImage.voidaddSearchCommand(ActionListener callback) This method add a search Command on the right bar of theToolbar.voidaddSearchCommand(ActionListener callback, float iconSize) This method add a search Command on the right bar of theToolbar.booleananimate()Allows the animation to reduce "repaint" calls when it returns false.voidCloses the left side menuvoidCloses the right side menuvoidCloses the current side menuprotected ContainerCreates an empty right side navigation panel.protected ContainerCreates an empty left side navigation panel.protected ListcreateOverflowCommandList(Vector commands) Creates the list component containing the commands within the given vector used for showing the menu dialogprotected ContainercreateSideNavigationComponent(Vector commands, String placement) Creates the side navigation component with the Commands.Find the command component instance if such an instance existsReturns the commands within the left bar section which can be useful for things like unit testing.Allows runtime manipulation of the side menu button, notice this will only work after the menu was createdReturns the associated SideMenuBar object of this Toolbar.Allows runtime manipulation of the overflow button, notice this will only work after the menu was createdReturns the commands within the overflow menu which can be useful for things like unit testing.Returns the commands within the right bar section which can be useful for things like unit testing.Allows runtime manipulation of the side menu button, notice this will only work after the menu was createdReturns the commands within the right side menu which can be useful for things like unit testing.Returns the commands within the left side menu which can be useful for things like unit testing.Returns the Toolbar title Component.voidHide the Toolbar if it is currently showingprotected voidAdds a status bar space to the north of the Component, subclasses can override this default behavior.static booleanIndicates whether the toolbar should be properly centered by defaultstatic booleanEnables/Disables the side menu bar swipe, defaults to truestatic booleanEnables/disables the Toolbar for all the forms in the application.static booleanIndicates if the side menu is in "on-top" modestatic booleanCreates a static side menu that doesn't fold instead of the standard sidemenu.booleanReturns true if the left or right side menu is open which is useful for walk through tours etc.booleanReturns true if the title is centered via the layoutvoidThis is a convenience method to open the right side menu bar.voidThis is a convenience method to open the left side menu bar.voidremoveCommand(Command cmd) Removes a Command from the MenuBarvoidRemoves the given overflow menu command, notice that this has no effect on the menu that is currently showing (if it is currently showing) only on the upcoming iterations.voidRemoves a previously installed search commandvoidsetBackCommand(Command cmd) Sets the back command in the title bar to an arrow type and maps the back command hardware key if applicable.voidsetBackCommand(Command cmd, Toolbar.BackCommandPolicy policy) Sets the back command in the title bar and in the form, back command behaves based on the given policy typevoidsetBackCommand(Command cmd, Toolbar.BackCommandPolicy policy, float iconSize) Sets the back command in the title bar and in the form, back command behaves based on the given policy typesetBackCommand(String title, ActionListener<ActionEvent> listener) Sets the back command in the title bar to an arrow type and maps the back command hardware key if applicable.setBackCommand(String title, Toolbar.BackCommandPolicy policy, ActionListener<ActionEvent> listener) Sets the back command in the title bar and in the form, back command behaves based on the given policy typestatic voidsetCenteredDefault(boolean aCenteredDefault) Indicates whether the toolbar should be properly centered by defaultvoidsetComponentToRightSideMenuSouth(Component sidemenuSouthComponent) Places a component in the south portion (bottom) of the right side menu.voidsetComponentToSideMenuSouth(Component sidemenuSouthComponent) Places a component in the south portion (bottom) of the left side menu.static voidsetEnableSideMenuSwipe(boolean aEnableSideMenuSwipe) Enables/Disables the side menu bar swipe, defaults to truestatic voidsetGlobalToolbar(boolean gt) Enables/disables the Toolbar for all the forms in the application.static voidsetOnTopSideMenu(boolean aOnTopSideMenu) Sets the side menu to "on-top" modestatic voidsetPermanentSideMenu(boolean p) Creates a static side menu that doesn't fold instead of the standard sidemenu.voidsetRightSideMenuCmdsAlignedToLeft(boolean toLeft) Normally on a right side menu the alignment should be "mirrored" in comparision with the left side menu, also for non-RTL languages: this method allows to change this default behaviour for non-RTL languages, forcing the alignment of the Commands of the right side menu to left.voidsetScrollOffUponContentPane(boolean scrollOff) Sets the Toolbar to scroll off the screen upon content scroll.voidSets the title of the Toolbar.voidsetTitleCentered(boolean cent) Makes the title align to the center accurately by doing it at the layout level which also takes into account right/left commandsvoidsetTitleComponent(Component titleCmp) Sets the Toolbar title component.protected CommandshowOverflowMenu(Dialog menu) voidshowSearchBar(ActionListener<ActionEvent> callback) Shows the search bar manually which is useful for use cases of popping up search from codevoidShow the Toolbar if it is currently not showingMethods inherited from class Container
add, add, add, add, add, add, addAll, addComponent, addComponent, addComponent, addComponent, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize, cancelRepaints, clearClientProperties, constrainHeightWhenScrollable, constrainWidthWhenScrollable, contains, createAnimateHierarchy, createAnimateHierarchyFade, createAnimateLayout, createAnimateLayoutFade, createAnimateLayoutFadeAndWait, createAnimateMotion, createAnimateUnlayout, createReplaceTransition, dragInitiated, drop, encloseIn, encloseIn, findDropTargetAt, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getChildrenAsList, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getResponderAt, getSafeAreaRoot, getScrollIncrement, getSideGap, getUIManager, initLaf, invalidate, isEnabled, isSafeArea, isSafeAreaRoot, isScrollableX, isScrollableY, isSelectableInteraction, isSurface, iterator, iterator, keyPressed, keyReleased, layoutContainer, morph, morphAndWait, paint, paintComponentBackground, paintGlass, paramString, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, revalidateLater, revalidateWithAnimationSafety, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setSafeArea, setSafeAreaRoot, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout, setUIManager, updateTabIndicesModifier and TypeMethodDescriptionfinal ContainerSimpler version of addComponent that allows chaining the calls for shorter syntaxSimpler version of addComponent that allows chaining the calls for shorter syntaxSimpler version of addComponent that allows chaining the calls for shorter syntaxSimpler version of addComponent that allows chaining the calls for shorter syntaxSimpler version of addComponent that allows chaining the calls for shorter syntaxSimpler version of addComponent that allows chaining the calls for shorter syntaxIdentical to add(x).add(y) only with a shorter syntaxvoidaddComponent(int index, Component cmp) This method adds the Component at a specific index location in the Container Components array.voidaddComponent(int index, Object constraints, Component cmp) Adds a Component to the ContainervoidaddComponent(Component cmp) Adds a Component to the ContainervoidaddComponent(Object constraints, Component cmp) Adds a Component to the ContainervoidanimateHierarchy(int duration) Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animationvoidanimateHierarchyAndWait(int duration) Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation.voidanimateHierarchyFade(int duration, int startingOpacity) Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animationvoidanimateHierarchyFadeAndWait(int duration, int startingOpacity) Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation.voidanimateLayout(int duration) Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animationvoidanimateLayoutAndWait(int duration) Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation.voidanimateLayoutFade(int duration, int startingOpacity) Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animationvoidanimateLayoutFadeAndWait(int duration, int startingOpacity) Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation.voidanimateUnlayout(int duration, int opacity, Runnable callback) This method is the exact reverse of animateLayout, when completed it leaves the container in an invalid state.voidanimateUnlayoutAndWait(int duration, int opacity) This method is the exact reverse of animateLayoutAndWait, when completed it leaves the container in an invalid state.voidapplyRTL(boolean rtl) Invokes apply/setRTL recursively on all the children components of this containerprotected DimensionCalculates the preferred size based on component content.protected voidremove this component and it's children from the painting queuevoidClears all client properties from this Componentprotected booleanIndicates that children's widths should be calculated as if this component weren't scrollable-X, even when the component is scrollable Y.protected booleanIndicates that children's widths should be calculated as if this component weren't scrollable-X, even when the component is scrollable X.booleanReturns true if the given component is within the hierarchy of this containercreateAnimateHierarchy(int duration) Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation.createAnimateHierarchyFade(int duration, int startingOpacity) Animates a pending hierarchy of components into place, this effectively replaces revalidate with a more visual form of animation.createAnimateLayout(int duration) Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animationcreateAnimateLayoutFade(int duration, int startingOpacity) Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animationcreateAnimateLayoutFadeAndWait(int duration, int startingOpacity) Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation.protected MotioncreateAnimateMotion(int start, int destination, int duration) Creates a motion object for animation, allows subclasses to replace the motion type used in animations (currently defaults to ease-in).createAnimateUnlayout(int duration, int opacity, Runnable callback) This method is the exact reverse of createAnimateLayout, when animation is completed it leaves the container in an invalid state.createReplaceTransition(Component current, Component next, Transition t) This method creates an animation component that replaces the current Component with the next Component.protected voidInvoked on the focus component to let it know that drag has started on the parent container for the case of a component that doesn't support scrollingvoidPerforms a drop operation of the component at the given X/Y location in coordinate space, this method should be overriden by subclasses to perform all of the logic related to moving a component, by default this method does nothing and so dragging a component and dropping it has no effectstatic ContainerShort-hand for enclosing multiple components in a container typically a box layoutstatic ContainerShort-hand for enclosing a component within a ContainerfindDropTargetAt(int x, int y) Recursively searches the container hierarchy for a drop targetFinds the first focusable Component on this Containerprotected voidWhen working in 3 softbutton mode "fire" key (center softbutton) is sent to this method in order to allow 3 button devices to work properly.voidFlushes ongoing replace operations to prevent two concurrent replace operations from colliding.voidA more powerful form of revalidate that recursively lays out the full hierarchyintReturns the gap to be left for the bottom scrollbar on the X axis.getChildrenAsList(boolean includeQueued) Gets the child components of this Container as a List.getClosestComponentTo(int x, int y) Very useful for touch events or drop events that need approximation more than accuracygetComponentAt(int index) Returns the Component at a given indexgetComponentAt(int x, int y) Returns a Component at coordinate (x, y).intReturns the number of componentsintReturns the Component index in the Containerprotected intThis method should be implemented correctly by subclasses to make snap to grid functionality work as expected.protected intThis method should be implemented correctly by subclasses to make snap to grid functionality work as expected.Returns the layout manager responsible for arranging this container.intReturns the height for layout manager purposes, this takes scrolling into consideration unlike the getHeight method.intReturns the width for layout manager purposes, this takes scrolling into consideration unlike the getWidth method.Returns the lead component for this hierarchy if such a component is definedReturns the lead container thats handling the leading, this is useful for a container hierarchy where the parent container might not be the leadergetResponderAt(int x, int y) Returns the top-most component that responds to pointer events at absolute coordinate (x, y).Gets the Safe area "root" container for this container.intGets the Container scroll incrementintReturns the gap to be left for the side scrollbar on the Y axis.This method should be used by the Component to retrieve the correct UIManager to work withprotected voidThis method initializes the Component defaults constantsvoidSame as setShouldCalcPreferredSize(true) but made accessible for layout managersbooleanIndicates whether component is enabled or disabled thus allowing us to prevent a component from receiving input events and indicate so visuallybooleanChecks if this container is a "safe area".booleanChecks if this container is a safe area root.booleanIndicates whether the component should/could scroll on the X axisbooleanIndicates whether the component should/could scroll on the Y axisprotected booleanThis method allows a component to indicate that it is interested in an "implicit" select command to appear in the "fire" button when 3 softbuttons are defined in a device.booleanChecks if this container acts as a Material Design surface.iterator()Part of the Iterable interface allowing us to do a for-each loop on Containeriterator(boolean includeQueued) Obtains an iterator that iterates over the children of this container.voidkeyPressed(int k) If this Component is focused, the key pressed event will call this methodvoidkeyReleased(int k) If this Component is focused, the key released event will call this methodvoidPerforms the layout of the container if a layout is necessaryvoidMorph is similar to the replace functionality where a component might be replaced with a component that isn't within the container.voidmorphAndWait(Component source, Component destination, int duration) Morph is similar to the replace functionality where a component might be replaced with a component that isn't within the container.voidThis method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.voidPaints this container background, skipping container background fill when fully obscured by children.protected voidThis method can be overriden by a component to draw on top of itself or its children after the component or the children finished drawing in a similar way to the glass pane but more refined per componentprotected StringReturns a string representing the state of this component.voidpointerPressed(int x, int y) If this Component is focused, the pointer pressed event will call this methodvoidrefreshTheme(boolean merge) Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!voidremove all Components from container, notice that removed component might still have a pending repaint in the queue that won't be removed.voidremoveComponent(Component cmp) removes a Component from the Container, notice that removed component might still have a pending repaint in the queue that won't be removed.voidreplace(Component current, Component next, Transition t) This method replaces the current Component with the next Component.voidreplace(Component current, Component next, Transition t, Runnable onFinish, int growSpeed) This method replaces the current Component with the next ComponentvoidreplaceAndWait(Component current, Component next, Transition t) This method replaces the current Component with the next Component.voidreplaceAndWait(Component current, Component next, Transition t, boolean dropEvents) This method replaces the current Component with the next Component.voidreplaceAndWait(Component current, Component next, Transition t, int layoutAnimationSpeed) This method replaces the current Component with the next Component.voidRe-layout the container, this is useful when we modify the container hierarchy and need to redo the layoutvoidRevalidates the container before the next paint cycle.voidRevalidates the container in a way that doesn't conflict with running animations.voidMakes sure the component is visible in the scroll if this container is scrollablevoidsetCellRenderer(boolean cellRenderer) Used as an optimization to mark that this component is currently being used as a cell renderervoidsetEnabled(boolean enabled) This method will recursively set all the Container chidrens to be enabled/disabled.voidSets the layout manager responsible for arranging this containerfinal voidsetLeadComponent(Component lead) Sets the lead component for this container, a lead component takes over the entire component hierarchy and receives all the events for the container hierarchy.voidsetSafeArea(boolean safeArea) Marks this container as a "safe area", meaning that it will automatically supply sufficient padding as necessary for its children to be laid out inside the safe area of the screen.voidsetSafeAreaRoot(boolean root) Set whether this container is a safe area root.voidsetScrollable(boolean scrollable) The equivalent of calling both setScrollableY and setScrollableXvoidsetScrollableX(boolean scrollableX) Sets whether the component should/could scroll on the X axisvoidsetScrollableY(boolean scrollableY) Sets whether the component should/could scroll on the Y axisvoidsetScrollIncrement(int scrollIncrement) Determines the scroll increment size of this Container.voidsetShouldCalcPreferredSize(boolean shouldCalcPreferredSize) Indicates the values within the component have changed and preferred size should be recalculatedprotected voidsetShouldLayout(boolean layout) Flags this container to preform layoutvoidsetUIManager(UIManager uiManager) Allows replacing the UIManager in a component hierarchy to update the look and feel only to a specific hierarchyintupdateTabIndices(int offset) Updates the tab indices in this container recursively.Methods inherited from class Component
addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, announceForAccessibility, bindProperty, blocksSideSwipe, calcScrollSize, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAccessibilityText, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getUIID, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAccessibilityText, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setPropertyValue, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUIIDFinal, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContainsModifier and TypeMethodDescriptionvoidAdds a listener to the dragFinished eventvoidBroadcasts an event when dragging over a componentvoidBinds an action listener to drop events which are invoked when this component is dropped on a targetvoidRegisters interest in receiving callbacks for focus gained events, a focus event is invoked when the component accepts the focus.voidAdds a listener to the pointer eventvoidAdds a listener to the pointer eventvoidAdds a listener to the pointer eventvoidAdds a listener to the pointer eventvoidaddPullToRefresh(Runnable task) This method adds a refresh task to the Component, the task will be executed if the user has pulled the scroll beyond a certain height.voidRegisters interest in receiving callbacks for scroll gained events, a scroll event is invoked when the component is scrolled.voidAdds a listener to be notified when the state of this component is changed to and from initialized.voidManually announces text to native accessibility services, associating the announcement with this component when possible.voidbindProperty(String prop, BindTarget target) Binds the given property name to the given bind targetfinal booleanA component that might need side swipe such as the slider could block it from being used for some other purpose when on top of said component.protected DimensionMethod that can be overriden to represent the actual size of the component when it differs from the desireable size for the viewportbooleancontains(int x, int y) Returns true if the given absolute coordinate is contained in the ComponentbooleancontainsOrOwns(int x, int y) Checks to see if this component either contains the given point, or if it owns the component that contains the given point.createStyleAnimation(String destUIID, int duration) Creates an animation that will transform the current component to the styling of the destination UIID when completed.protected voidInvoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.protected voidAllows components to create a style of their own, this method cleans up state for the given styleprotected voidThis callback method indicates that a component drag has just entered this componentprotected voidThis callback method provides an indication for a drop target that a drag operation is exiting the bounds of this component and it should clear all relevant state if such state exists.protected voiddragFinished(int x, int y) Callback indicating that the drag has finished either via drop or by releasing the componentprotected booleandraggingOver(Component dragged, int x, int y) This method allows a component to indicate if it is a drop target for the given component at the given x/y location (in component coordiate space).protected voiddrawDraggedImage(Graphics g, Image img, int x, int y) Draws the given image at x/y, this method can be overriden to draw additional information such as positive or negative drop indicationprotected voidCallback allowing a developer to track when the component gains focusprotected voidCallback allowing a developer to track wheh the component loses focusintReturns the absolute X location based on the component hierarchy, this method calculates a location on the screen for the component rather than a relative location as returned by getX()intReturns the absolute Y location based on the component hierarchy, this method calculates a location on the screen for the component rather than a relative location as returned by getX()Returns the text that describes this component to assistive technologies.final StyleReturns a "meta style" that allows setting styles once to all the different Style objects, the getters for this style will be meaningless and will return 0 values.Returns the animation manager of the parent form or null if this component isn't currently associated with a formintgetBaseline(int width, int height) The baseline for the component text according to which it should be aligned with other components for best visual look.intReturns a constant indicating how the baseline varies with the size of the component.String[]Returns the names of the properties within this component that can be bound for persistence, the order of these names mean that the first one will be the first boundClass[]Returns the types of the properties that are bindable within this componentprotected BorderNormally returns getStyle().getBorder() but some subclasses might use this to programmatically replace the border in runtime e.g.getBoundPropertyValue(String prop) Allows the binding code to extract the value of the propertyprotected RectangleReturns the component bounds which is sometimes more convenient than invoking getX/Y/Width/Height.Returns the bounds of this component in the provided Rectangle.getClientProperty(String key) Client properties allow the association of meta-data with a component, this is useful for some applications that construct GUI's on the fly and need to track the connection between the UI and the data.Indicates the property within this component that should be bound to the cloud objectThe destination property of the CloudObjectReturns the Component Form or null if this Component is not added yet to a formSome components may optionally generate a state which can then be restored using setCompnentState().intGets the custom cursor for this component.static byteReturns the default translucency used in the#getDragImage()method.final Rectanglegets the Component dirty region, this method is for internal use only and SHOULD NOT be invoked by user code.Returns the Component Style for the disabled state allowing us to manipulate the look of the component when its disabledintGets the current dragged x values when the Component is being draggedintGets the current dragged y values when the Component is being draggedprotected ImageThis method returns an image representing the dragged component, it can be overriden by subclasses to customize the look of the image, the image will be overlaid on top of the form during a drag and drop operationprotected intgetDragRegionStatus(int x, int y) Indicates if the section within the X/Y area is a "drag region" where we expect people to drag or press in which case we can instantly start dragging making perceived performance faster.protected floatgetDragSpeed(boolean vertical) This method returns the dragging speed based on the latest dragged eventsbyteReturns the translucency used in the#getDragImage()method.Gets the delegate that handles the editing of this component.intReturns the component heightGets inline styles that are to be applied to all states of this component.Gets inline styles that are to be applied to the disabled state of this component.Gets inline styles that are to be applied to the pressed state of this component.Gets inline styles that are to be applied to the selected state of this component.Gets the theme that is used by inline styles to reference images.Gets inline styles that are to be applied to the unselected state of this component.intGets the inner height of this component.intGets the preferred height removing vertical padding.intGets the preferred width removing horizontal padding.intGets the inner width of this component.intGets x-coordinate of the inner bounds of this component.intGets the inner y-coordinate of the inner bounds of this component.Allows us to indicate the label associated with this component thus providing visual feedback related for this component e.g.getName()A component name allows us to easily identify the component within a dynamic UI.Gets the native overlay for this component.Allows us to determine which component will receive focus next when traversing with the down keyAllows us to determine which component will receive focus next when traversing with the left key.Allows us to determine which component will receive focus next when traversing with the right keyAllows us to determine which component will receive focus next when traversing with the up key.intGets the outer height of this component.intGets the preferred height including the vertical margins.intGets the preferred width including horizontal margins.intGets the outer width of this component.intGets the x-coordinate of the outer bounds of this component.intGets the Y-coordinate of the outer bounds of this component.getOwner()Gets the "owner" of this component as set by#setOwner(com.codename1.ui.Component).Returns the container in which this component is containedintHelper method to retrieve the preferred height of the component.Returns the Component Preferred Size, there is no guarantee the Component will be sized at its Preferred Size.Returns the preferred size string that can be used to specify the preferred size of the component using pixels or millimetres.intGets the preferred tab index of this component.intHelper method to retrieve the preferred width of the component.Returns the Component Style for the pressed state allowing us to manipulate the look of the component when it is pressedString[]A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder codeString[]This method is here to workaround an XMLVM array type bug where property types aren't identified properly, it returns the names of the types using the following type names: String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,ListCellRendererClass[]Matches the property names method (see that method for further details).getPropertyValue(String name) Returns the current value of the property name, this method is used by the GUI builderReturns the array of components that have an equal heightReturns the array of components that have an equal widthReturns the scrollable parent of this componentintScroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation modeReturns the Components dimension in scrolling, this is very similar to the preferred size aspect only it represents actual scrolling limits.intThis method is used internally by the look and feel to implement the fading scrollbar behavior.intIndicates the decrement units for the scroll opacityintIndicates the X position of the scrolling, this number is relative to the component position and so a position of 0 would indicate the x position of the component.intIndicates the Y position of the scrolling, this number is relative to the component position and so a position of 0 would indicate the y position of the component.Allows determining the text for the select command used in the 3rd softbutton mode.Returns the component bounds with absolute screen coordinates, for components that include an internal selection behavior and are not containers (currently only List) this method allows returning the position of the selection itself which is useful for things such as the popup dialog and similar UI's that need to reference the position of the selection externallyReturns the Component Style for the selected state allowing us to manipulate the look of the component when it owns focusgetStyle()Returns the current Component Style allowing code to draw the current component, you should normally use getUnselected/Pressed/DisabledStyle() and not this method since it will return different values based on component state.intGets the tab index of the component.intRecommended length for the tensile, -1 for defaultReturns text selection support object for this component.Returns
final StringgetUIID()Unique identifier for a component.final StyleReturns the Component Style for the unselected mode allowing us to manipulate the look of the componentprotected RectangleReturns the component bounds for scrolling which might differ from the getBounds for large components e.g.getVisibleBounds(Rectangle rect) Returns the component bounds for scrolling which might differ from the getBounds for large components into the provided rectangle.intgetWidth()Returns the component widthintgetX()Returns the current component x location relatively to its parent containerintgetY()Returns the component y location relatively to its parent containervoidgrowShrink(int duration) Grows or shrinks this component to its new preferred size, this method essentially takes a component whose preferred size has changed and creates a "growing" effect that lasts for the duration.booleanPrevents key events from being grabbed for focus traversal.booleanChecks if this component has a fixed preferred size either via an explicit call to#setPreferredH(int)and#setPreferredW(int), or via a preferred size style string.booleanhasFocus()Returns true if the component has focusprotected voidHides the native overlay for this component.protected voidAllows subclasses to bind functionality that relies on fully initialized and "ready for action" component stateprotected voidAllows components to create a style of their own, this method binds the listener to the style and installs a bg painterprotected voidinitDisabledStyle(Style disabledStyle) Can be overridden by subclasses to perform initialization when the disabled style is set to a new value.protected voidinitPressedStyle(Style pressedStyle) Can be overridden by subclasses to perform initialization when the pressed style is set to a new value.protected voidinitSelectedStyle(Style selectedStyle) Can be overridden by subclasses to perform initialization when the selected style is set to a new value.protected voidinitUnselectedStyle(Style unselectedStyle) Can be overridden by subclasses to perform initialization when the unselected style is set to a new value.protected voidAllows subclasses to create their own custom style types and install the background painter into thembooleanEnable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)booleanPrevent a lead component hierarchy from this specific component, this allows a component within that hierarchy to still act as a standalone componentbooleanUsed as an optimization to mark that this component is currently being used as a cell rendererbooleanSearches the hierarchy of the component recursively to see if the given Container is one of the parents of this componentprotected booleanIndicates whether we are in the middle of a drag operation, this method allows developers overriding the pointer released events to know when this is a drag operation.protected booleanisDragAndDropOperation(int x, int y) This method allows a developer to define only a specific portion of a component as draggable by default it returns true if the component is defined as "draggable"booleanIndicates whether this component can be dragged in a drag and drop operation rather than scroll the parentprotected booleanisDragRegion(int x, int y) Indicates if the section within the X/Y area is a "drag region" where we expect people to drag and never actually "press" in which case we can instantly start dragging making perceived performance faster.booleanIndicates whether this component can receive dropped components into it, notice that when dropping on a component or container the parents will be checked recursively to find a valid drop targetbooleanChecks to see if the component is editable.booleanChecks if the component is currently being edited.booleanMakes the component effectively opaque by blending the backgrounds into an image in memory so the layer of underlying components is only drawn once when this component is repainted.booleanReturns true if this component can receive focus and is enabledbooleanThis property is useful for blocking in z-order touch events, sometimes we might want to grab touch events in a specific component without making it focusable.booleanisHidden()Returns true if the component was explicitly hidden by the user.booleanisHidden(boolean checkParent) Checks if the component is hidden.booleanIndicates that this component and all its children should be hidden when the device is switched to landscape modebooleanIndicates that this component and all its children should be hidden when the device is switched to portrait modebooleanReturns
protected booleanprotected booleanIndicates if the component is in the initialized state, a component is initialized when its initComponent() method was invoked.booleanisOpaque()Checks whether the component's background should be painted.booleanChecks to see if this component is owned by the given other component.booleanreturns true if pinch will block drag and dropbooleanIndicates whether the component displays the material design ripple effectfinal booleanisRTL()Is the component a bidi RTL componentprotected booleanIndicates whether the component should/could scroll by default a component is not scrollable.booleanIndicate whether this component scroll is visiblestatic booleanChecks to see if this platform supports cursors.booleanIndicates that scrolling through the component should work as an animationbooleanIndicates whether scrolling this component should jump to a specific location in a gridprotected booleanReturns true if the component is interested in receiving drag/pointer release events even after the gesture exceeded its boundaries.booleanIndicates whether the component should "trigger" tactile touch when pressed by the user in a touch screen UI.protected booleanisTactileTouch(int x, int y) Elaborate components might not provide tactile feedback for all their areas (e.g. Lists) this method defaults to returning the value of isTactileTouchbooleanIndicates whether tensile drag (dragging beyond the boundry of the component and snapping back) is enabled for this component.final booleanChecks if this component should be traversable using the keyboard using tab, next, previous keys.booleanReturns whether the component is visible or notvoidkeyRepeated(int keyCode) If this Component is focused, the key repeat event will call this method.protected voidlaidOut()This is a callback method to inform the Component when it's been laidout on the parent Containerprotected voidlongKeyPress(int keyCode) If this Component is focused this method is invoked when the user presses and holds the keyvoidlongPointerPress(int x, int y) If this Component is focused this method is invoked when the user presses and holds the pointer on the Componentprotected voidonScrollX(int scrollX) This method can be overriden to receive scroll events, unlike overriding setScrollX it will receive all calls for scrolling.protected voidonScrollY(int scrollY) This method can be overriden to receive scroll events, unlike overriding setScrollY it will receive all calls for scrolling.protected voidonSetFocusable(boolean focusable) Since setFocusable is final this callback is invoked when focusable changes.protected voidThis method paints the Component background, it should be overriden by subclasses to perform custom background drawing.voidThis method paints all the parents Components Background.protected voidDraws the component border if such a border exists.protected voidDraws the component border background if such a border exists.final voidPaints this component as a root by going to all the parent components and setting the absolute translation based on coordinates and scroll status.final voidpaintComponent(Graphics g, boolean background) Paints this component as a root by going to all the parent components and setting the absolute translation based on coordinates and scroll status.voidPaints intersecting components that appear above this component.paintLock(boolean hardLock) This method locks the component so it will always paint the given image instead of running through its paint logic.voidReleases the paint lock image to allow paint to work as usual, see paintLock(boolean) for detailsvoidpaintRippleOverlay(Graphics g, int x, int y, int position) Invoked to draw the ripple effect overlay in Android where the finger of the user causes a growing circular overlay over time.protected voidPaints the UI for the scrollbars on the component, this will be invoked only for scrollable components.protected voidPaints the UI for the scrollbar on the X axis, this method allows component subclasses to customize the look of a scrollbarprotected voidPaints the UI for the scrollbar on the Y axis, this method allows component subclasses to customize the look of a scrollbarvoidpaintShadows(Graphics g, int relativeX, int relativeY) Paints the drop-shadow projections for this component based on its elevation value.static DimensionparsePreferredSize(String preferredSize, Dimension baseSize) Parses the preferred size given as a stringprotected booleanpinch(float scale) Invoked by subclasses interested in handling pinch to zoom events, if true is returned other drag events will not be broadcastprotected booleanpinch(int[] x, int[] y) Invoked by subclasses interested in handling pinch to do their own actions based on the position of the two fingers, if true is returned other drag events will not be broadcastprotected voidpinchReleased(int x, int y) To be implemented by subclasses interested in being notified when a pinch zoom has ended (i.e the user has removed one of their fingers, but is still dragging).voidpointerDragged(int[] x, int[] y) If this Component is focused, the pointer dragged event will call this methodvoidpointerDragged(int x, int y) If this Component is focused, the pointer dragged event will call this methodvoidpointerHover(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display.voidpointerHoverPressed(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display.voidpointerHoverReleased(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display.voidpointerPressed(int[] x, int[] y) If this Component is focused, the pointer pressed event will call this methodvoidpointerReleased(int[] x, int[] y) If this Component is focused, the pointer released event will call this methodvoidpointerReleased(int x, int y) If this Component is focused, the pointer released event will call this methodvoidputClientProperty(String key, Object value) Client properties allow the association of meta-data with a component, this is useful for some applications that construct GUI's on the fly and need to track the connection between the UI and the data.voidMakes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!protected voidrefreshTheme(String id, boolean merge) Makes sure the component is up to date with the given UIIDvoidremove()This method will remove the Component from its parent.voidRemoves the listener from the drag finished eventvoidRemoves an action listener to drag over eventsvoidRemoves an action listener to drop events which are invoked when this component is dropped on a targetvoidDeregisters interest in receiving callbacks for focus gained eventsvoidRemoves the listener from the pointer eventvoidRemoves the listener from the pointer eventvoidRemoves the listener from the pointer eventvoidRemoves the listener from the pointer eventvoidDeregisters interest in receiving callbacks for scroll gained eventsvoidRemoves a listener from being notified when the state of this component is changed to and from initialized.voidrepaint()Repaint this Component, the repaint call causes a callback of the paint method on the event dispatch thread.voidrepaint(int x, int y, int w, int h) Repaints a specific region within the componentvoidChanges the current component to the focused component, will work only for a component that belongs to a parent form.protected voidRestores the state of the focusable flag to its default statebooleanChecks if the component responds to pointer events.voidscrollRectToVisible(int x, int y, int width, int height, Component coordinateSpace) Makes sure the component is visible in the scroll if this container is scrollableprotected voidscrollRectToVisible(Rectangle rect, Component coordinateSpace) Makes sure the component is visible in the scroll if this container is scrollablevoidsetAccessibilityText(String text) Sets the text that describes this component to assistive technologies.voidsetAlwaysTensile(boolean alwaysTensile) Enable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)voidsetBlockLead(boolean blockLead) Prevent a lead component hierarchy from this specific component, this allows a component within that hierarchy to still act as a standalone componentvoidsetBoundPropertyValue(String prop, Object value) Sets the value of a bound property within this component, notice that this method MUST NOT fire the property change event when invoked to prevent recursion!voidsetCloudBoundProperty(String cloudBoundProperty) Indicates the property within this component that should be bound to the cloud objectvoidsetCloudDestinationProperty(String cloudDestinationProperty) The destination property of the CloudObjectvoidsetComponentState(Object state) If getComponentState returned a value the setter can update the value and restore the prior state.voidsetCursor(int cursor) Sets a custom mouse cursor for this component if the platform supports mouse cursors, notice that this isn't applicable for touch devices.static voidsetDefaultDragTransparency(byte defaultDragTransparency) Sets the default translucency of the#getDragImage()method.final voidsetDirtyRegion(Rectangle dirty) sets the Component dirty region, this method is for internal use only and SHOULD NOT be invoked by user code.voidsetDisabledStyle(Style style) Changes the Component disalbed Style by replacing the Component Style with the given StylevoidsetDraggable(boolean draggable) Indicates whether this component can be dragged in a drag and drop operation rather than scroll the parentvoidsetDragTransparency(byte dragTransparency) Sets the translucency of the#getDragImage()method.voidsetDropTarget(boolean dropTarget) Indicates whether this component can receive dropped components into it, notice that when dropping on a component or container the parents will be checked recursively to find a valid drop targetvoidsetEditingDelegate(Editable editable) Sets the editing delegate for this component.voidsetFlatten(boolean flatten) Makes the component effectively opaque by blending the backgrounds into an image in memory so the layer of underlying components is only drawn once when this component is repainted.voidsetFocus(boolean focused) This flag doesn't really give focus, its a state that determines what colors from the Style should be used when painting the component.final voidsetFocusable(boolean focusable) A simple setter to determine if this Component can get focusedvoidsetGrabsPointerEvents(boolean grabsPointerEvents) This property is useful for blocking in z-order touch events, sometimes we might want to grab touch events in a specific component without making it focusable.voidsetHandlesInput(boolean handlesInput) Prevents key events from being grabbed for focus traversal.voidsetHeight(int height) Sets the Component height, this method is exposed for the purpose of external layout managers and should not be invoked directly.voidsetHidden(boolean b) Makes the components preferred size equal 0 when hidden and restores it to the default size when not.voidsetHidden(boolean b, boolean changeMargin) Makes the components preferred size equal 0 when hidden and restores it to the default size when not.voidsetHideInLandscape(boolean hideInLandscape) Indicates that this component and all its children should be hidden when the device is switched to landscape modevoidsetHideInPortrait(boolean hideInPortrait) Indicates that this component and all its children should be hidden when the device is switched to portrait modevoidsetIgnorePointerEvents(boolean ignorePointerEvents) Parameters
protected voidsetInitialized(boolean initialized) Indicates if the component is in the initialized state, a component is initialized when its initComponent() method was invoked.voidsetInlineAllStyles(String styles) Registers inline styles that should be applied to all states of the component.voidsetInlineDisabledStyles(String styles) Registers inline styles that should be applied to the disabled state of the component.voidsetInlinePressedStyles(String styles) Registers inline styles that should be applied to the pressed state of the component.voidsetInlineSelectedStyles(String styles) Registers inline styles that should be applied to the selected state of the component.voidsetInlineStylesTheme(Resources inlineStylesTheme) Sets the theme that is used by inline styles to reference images.voidsetInlineUnselectedStyles(String styles) Registers inline styles that should be applied to the unselected state of the component.voidsetIsScrollVisible(boolean isScrollVisible) Set whether this component scroll is visiblevoidsetLabelForComponent(Label componentLabel) Allows us to indicate the label associated with this component thus providing visual feedback related for this component e.g.voidA component name allows us to easily identify the component within a dynamic UI.voidsetNextFocusDown(Component nextFocusDown) Allows us to determine which component will receive focus next when traversing with the down keyvoidsetNextFocusLeft(Component nextFocusLeft) Allows us to determine which component will receive focus next when traversing with the left key, this method doesn't affect the general focus behavior.voidsetNextFocusRight(Component nextFocusRight) Allows us to determine which component will receive focus next when traversing with the right keyvoidsetNextFocusUp(Component nextFocusUp) Allows us to determine which component will receive focus next when traversing with the up key, this method doesn't affect the general focus behavior.final voidsetOpaque(boolean opaque) Sets whether or not to paint the component background.voidSets the owner of this component to the specified component.voidsetPinchBlocksDragAndDrop(boolean block) If a component supports pinch as well as drag and drop the two may conflict (if one finger is placed a bit before the other, the drag timer will be initiated and may trigger drag even if the second finger has been placed before).voidsetPreferredH(int preferredH) Helper method to set the preferred height of the component.voidSets the Component Preferred Size, there is no guarantee the Component will be sized at its Preferred Size.voidsetPreferredSizeStr(String value) Parameters
voidsetPreferredTabIndex(int index) Sets the preferred tab index of the component.voidsetPreferredW(int preferredW) Helper method to set the preferred width of the component.voidsetPressedStyle(Style style) Sets the Component Style for the pressed state allowing us to manipulate the look of the component when it is pressedsetPropertyValue(String name, Object value) Sets a new value to the given property, returns an error message if failed and null if successful.voidsetRippleEffect(boolean rippleEffect) Indicates whether the component displays the material design ripple effectvoidsetRTL(boolean rtl) Is the component a bidi RTL componentstatic voidsetSameHeight(Component... c) Places all of these components in the same height group, to remove a component from the group invoke this method with that component only.static voidsetSameSize(Component... c) This is identical to invoking#sameWidthfollowed by#sameHeightstatic voidsetSameWidth(Component... c) Places all of these components in the same width group, to remove a component from the group invoke this method with that component only.voidsetScrollAnimationSpeed(int animationSpeed) Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation modevoidsetScrollOpacityChangeSpeed(int scrollOpacityChangeSpeed) Indicates the decrement units for the scroll opacityvoidSet the size for the scroll areavoidsetScrollVisible(boolean isScrollVisible) Set whether this component scroll is visibleprotected voidsetScrollX(int scrollX) Indicates the X position of the scrolling, this number is relative to the component position and so a position of 0 would indicate the x position of the component.protected voidsetScrollY(int scrollY) Indicates the Y position of the scrolling, this number is relative to the component position and so a position of 0 would indicate the y position of the component.voidsetSelectCommandText(String selectText) Allows determining the text for the select command used in the 3rd softbutton mode.voidsetSelectedStyle(Style style) Changes the Component selected Style by replacing the Component Style with the given StylevoidSets the Component size, this method is exposed for the purpose of external layout managers and should not be invoked directly.voidsetSmoothScrolling(boolean smoothScrolling) Indicates that scrolling through the component should work as an animationvoidsetSnapToGrid(boolean snapToGrid) Indicates whether scrolling this component should jump to a specific location in a gridvoidsetTabIndex(int index) Sets the tab index of the component.voidsetTactileTouch(boolean tactileTouch) Indicates whether the component should "trigger" tactile touch when pressed by the user in a touch screen UI.voidsetTensileDragEnabled(boolean tensileDragEnabled) Indicates whether tensile drag (dragging beyond the boundry of the component and snapping back) is enabled for this component.voidsetTensileLength(int tensileLength) Recommended length for the tensile, -1 for defaultvoidsetTooltip(String tooltip) Parameters
final voidsetTraversable(boolean traversable) Sets whether this component is traversable using the keyboard using tab, next, previous keys.voidThis method sets the Component the Unique identifier.voidThis method sets the Component the Unique identifier.protected final voidsetUIIDFinal(String id) This method is the implementation of setUIID and is defined as final to allow invocation from constructors.voidsetUnselectedStyle(Style style) Changes the Component Style by replacing the Component Style with the given StylevoidsetVisible(boolean visible) Toggles visibility of the componentvoidsetWidth(int width) Sets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly.voidsetX(int x) Sets the Component x location relative to the parent container, this method is exposed for the purpose of external layout managers and should not be invoked directly.voidsetY(int y) Sets the Component y location relative to the parent container, this method is exposed for the purpose of external layout managers and should not be invoked directly.protected booleanA component that might need side swipe such as the slider could block it from being used for some other purpose when on top of said component.protected booleanA component that might need side swipe such as the tabs could block it from being used for some other purpose when on top of said component.protected booleanA component that might need side swipe such as the tabs could block it from being used for some other purpose when on top of said component.protected booleanA component can indicate whether it is interested in rendering it's selection explicitly, this defaults to true in non-touch UI's and false in touch UI's except for the case where a user clicks the screen.protected voidCreates the native overlay for this component.voidIf the component#isEditable(), then this will start the editing process.voidstopEditing(Runnable onFinish) Stops the editing process.Convenience method that strips margin and padding from the component, and returns itself for chaining.voidstyleChanged(String propertyName, Style source) Invoked to indicate a change in a propertyName of a StyletoImage()Returns the component as an image.toString()Overriden to return a useful value for debugging purposesvoidunbindProperty(String prop, BindTarget target) Removes a bind target from the given property nameprotected voidUpdates the native overlay for this component.booleanvisibleBoundsContains(int x, int y) Returns true if the given absolute coordinate is contained inside the visible bounds of the component.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()booleanIndicates whether some other object is "equal to" this one.final ClassgetClass()Returns the runtime class of an object.inthashCode()Returns a hash code value for the object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.final voidwait()Causes current thread to wait until another thread invokes the method or the method for this object.final voidwait(long timeout) Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.final voidwait(long timeout, int nanos) Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
-
Constructor Details
-
Toolbar
public Toolbar()Empty Constructor -
Toolbar
public Toolbar(boolean layered) This constructor places the Toolbar on a different layer on top of the Content Pane.
Parameters
layered: if true places the Toolbar on top of the Content Pane
-
-
Method Details
-
isCenteredDefault
public static boolean isCenteredDefault()Indicates whether the toolbar should be properly centered by default
Returns
the centeredDefault
-
setCenteredDefault
public static void setCenteredDefault(boolean aCenteredDefault) Indicates whether the toolbar should be properly centered by default
Parameters
aCenteredDefault: the centeredDefault to set
-
isOnTopSideMenu
public static boolean isOnTopSideMenu()Indicates if the side menu is in "on-top" mode
Returns
the onTopSideMenu
-
setOnTopSideMenu
public static void setOnTopSideMenu(boolean aOnTopSideMenu) Sets the side menu to "on-top" mode
Parameters
aOnTopSideMenu: the onTopSideMenu to set
-
isEnableSideMenuSwipe
public static boolean isEnableSideMenuSwipe()Enables/Disables the side menu bar swipe, defaults to true
Returns
the enableSideMenuSwipe
-
setEnableSideMenuSwipe
public static void setEnableSideMenuSwipe(boolean aEnableSideMenuSwipe) Enables/Disables the side menu bar swipe, defaults to true
Parameters
aEnableSideMenuSwipe: the enableSideMenuSwipe to set
-
isGlobalToolbar
public static boolean isGlobalToolbar()Enables/disables the Toolbar for all the forms in the application. This flag can be flipped via the theme constant
globalToobarBool. Notice that the name of this method might imply that one toolbar instance will be used for all forms which isn't the case, separate instances will be used for each formReturns
true if the toolbar API is turned on by default
-
setGlobalToolbar
public static void setGlobalToolbar(boolean gt) Enables/disables the Toolbar for all the forms in the application. This flag can be flipped via the theme constant
globalToobarBool. Notice that the name of this method might imply that one toolbar instance will be used for all forms which isn't the case, separate instances will be used for each formParameters
gt: true to enable the toolbar globally
-
isPermanentSideMenu
public static boolean isPermanentSideMenu()Creates a static side menu that doesn't fold instead of the standard sidemenu. This is common for tablet UI's where folding the side menu doesn't make as much sense.
Returns
true if we will use a permanent sidemenu
-
setPermanentSideMenu
public static void setPermanentSideMenu(boolean p) Creates a static side menu that doesn't fold instead of the standard sidemenu. This is common for tablet UI's where folding the side menu doesn't make as much sense.
Parameters
p: true to have a permanent side menu
-
setTitle
Sets the title of the Toolbar.
Parameters
title: the Toolbar title
-
isTitleCentered
public boolean isTitleCentered()Returns true if the title is centered via the layout
Returns
true if the title is centered
-
setTitleCentered
public void setTitleCentered(boolean cent) Makes the title align to the center accurately by doing it at the layout level which also takes into account right/left commands
Parameters
cent: whether the title should be centered
-
openSideMenu
public void openSideMenu()This is a convenience method to open the left side menu bar. It's useful for cases where we want to place the menu button in a "creative way" in which case we can bind the side menu to this -
isSideMenuShowing
public boolean isSideMenuShowing()Returns true if the left or right side menu is open which is useful for walk through tours etc. -
openRightSideMenu
public void openRightSideMenu()This is a convenience method to open the right side menu bar. It's useful for cases where we want to place the menu button in a "creative way" in which case we can bind the side menu to this -
closeSideMenu
public void closeSideMenu()Closes the current side menu -
closeLeftSideMenu
public void closeLeftSideMenu()Closes the left side menu -
closeRightSideMenu
public void closeRightSideMenu()Closes the right side menu -
getTitleComponent
Returns the Toolbar title Component.
Returns
the Toolbar title component
-
setTitleComponent
Sets the Toolbar title component. This method allow placing any component in the Toolbar center instead of the regular Label. Can be used to place a TextField to perform search operations
Parameters
titleCmp: Component to place in the Toolbar center.
-
addCommandToOverflowMenu
Adds a Command to the overflow menu
Parameters
-
name: the name/title of the command -
icon: the icon for the command -
ev: the even handler
Returns
a newly created Command instance
-
-
setBackCommand
Sets the back command in the title bar to an arrow type and maps the back command hardware key if applicable. This is functionally identical to
setBackCommand(title, Toolbar.BackCommandPolicy.AS_ARROW, listener);Parameters
-
title: command title -
listener: action event for the back command
Returns
the created command
-
-
setBackCommand
Sets the back command in the title bar to an arrow type and maps the back command hardware key if applicable. This is functionally identical to
setBackCommand(cmd, Toolbar.BackCommandPolicy.AS_ARROW);Parameters
cmd: the command
-
setBackCommand
public Command setBackCommand(String title, Toolbar.BackCommandPolicy policy, ActionListener<ActionEvent> listener) Sets the back command in the title bar and in the form, back command behaves based on the given policy type
Parameters
-
title: command title -
policy: the behavior of the back command in the title -
listener: action event for the back command
Returns
the created command
-
-
setBackCommand
Sets the back command in the title bar and in the form, back command behaves based on the given policy type
Parameters
-
cmd: the command -
policy: the behavior of the back command in the title -
iconSize: the size of the back command icon in millimeters
-
-
setBackCommand
Sets the back command in the title bar and in the form, back command behaves based on the given policy type
Parameters
-
cmd: the command -
policy: the behavior of the back command in the title
-
-
addSearchCommand
This method add a search Command on the right bar of the
Toolbar. When the search Command is invoked the currentToolbaris replaced with a searchToolbarto perform a search on the Current Form.The callback ActionListener gets the search string and it's up to developer to do the actual filtering on the Form.
It is possible to customize the default look of the search
Toolbarwith the following uiid's:ToolbarSearch,TextFieldSearch&TextHintSearch.Image duke = null; try { duke = Image.createImage("/duke.png"); } catch(IOException err) { Log.e(err); } int fiveMM = Display.getInstance().convertToPixels(5); final Image finalDuke = duke.scaledWidth(fiveMM); Toolbar.setGlobalToolbar(true); Form hi = new Form("Search", BoxLayout.y()); hi.add(new InfiniteProgress()); Display.getInstance().scheduleBackgroundTask(()-> { // this will take a while... Contact[] cnts = Display.getInstance().getAllContacts(true, true, true, true, false, false); Display.getInstance().callSerially(() -> { hi.removeAll(); for(Contact c : cnts) { MultiButton m = new MultiButton(); m.setTextLine1(c.getDisplayName()); m.setTextLine2(c.getPrimaryPhoneNumber()); Image pic = c.getPhoto(); if(pic != null) { m.setIcon(fill(pic, finalDuke.getWidth(), finalDuke.getHeight())); } else { m.setIcon(finalDuke); } hi.add(m); } hi.revalidate(); }); }); hi.getToolbar().addSearchCommand(e -> { String text = (String)e.getSource(); if(text == null || text.length() == 0) { // clear search for(Component cmp : hi.getContentPane()) { cmp.setHidden(false); cmp.setVisible(true); } hi.getContentPane().animateLayout(150); } else { text = text.toLowerCase(); for(Component cmp : hi.getContentPane()) { MultiButton mb = (MultiButton)cmp; String line1 = mb.getTextLine1(); String line2 = mb.getTextLine2(); boolean show = line1 != null && line1.toLowerCase().indexOf(text) > -1 || line2 != null && line2.toLowerCase().indexOf(text) > -1; mb.setHidden(!show); mb.setVisible(show); } hi.getContentPane().animateLayout(150); } }, 4); hi.show();Parameters
-
callback: gets the search string callbacks -
iconSize: @param iconSize indicates the size of the icons used in the search/back in millimeters
-
-
showSearchBar
Shows the search bar manually which is useful for use cases of popping up search from code
Parameters
callback: gets the search string callbacks
-
removeSearchCommand
public void removeSearchCommand()Removes a previously installed search command -
addSearchCommand
This method add a search Command on the right bar of the
Toolbar. When the search Command is invoked the currentToolbaris replaced with a searchToolbarto perform a search on the Current Form.The callback ActionListener gets the search string and it's up to developer to do the actual filtering on the Form.
It is possible to customize the default look of the search
Toolbarwith the following uiid's:ToolbarSearch,TextFieldSearch&TextHintSearch.Image duke = null; try { duke = Image.createImage("/duke.png"); } catch(IOException err) { Log.e(err); } int fiveMM = Display.getInstance().convertToPixels(5); final Image finalDuke = duke.scaledWidth(fiveMM); Toolbar.setGlobalToolbar(true); Form hi = new Form("Search", BoxLayout.y()); hi.add(new InfiniteProgress()); Display.getInstance().scheduleBackgroundTask(()-> { // this will take a while... Contact[] cnts = Display.getInstance().getAllContacts(true, true, true, true, false, false); Display.getInstance().callSerially(() -> { hi.removeAll(); for(Contact c : cnts) { MultiButton m = new MultiButton(); m.setTextLine1(c.getDisplayName()); m.setTextLine2(c.getPrimaryPhoneNumber()); Image pic = c.getPhoto(); if(pic != null) { m.setIcon(fill(pic, finalDuke.getWidth(), finalDuke.getHeight())); } else { m.setIcon(finalDuke); } hi.add(m); } hi.revalidate(); }); }); hi.getToolbar().addSearchCommand(e -> { String text = (String)e.getSource(); if(text == null || text.length() == 0) { // clear search for(Component cmp : hi.getContentPane()) { cmp.setHidden(false); cmp.setVisible(true); } hi.getContentPane().animateLayout(150); } else { text = text.toLowerCase(); for(Component cmp : hi.getContentPane()) { MultiButton mb = (MultiButton)cmp; String line1 = mb.getTextLine1(); String line2 = mb.getTextLine2(); boolean show = line1 != null && line1.toLowerCase().indexOf(text) > -1 || line2 != null && line2.toLowerCase().indexOf(text) > -1; mb.setHidden(!show); mb.setVisible(show); } hi.getContentPane().animateLayout(150); } }, 4); hi.show();Parameters
callback: gets the search string callbacks
-
addCommandToOverflowMenu
Adds a Command to the overflow menu
Parameters
cmd: a Command
-
getOverflowCommands
-
addCommandToSideMenu
Adds a Command to the left or right side navigation menu according to the state of RTL.
Parameters
-
name: the name/title of the command -
icon: the icon for the command -
ev: the even handler
Returns
a newly created Command instance
-
-
addCommandToLeftSideMenu
Adds a Command to the left side navigation menu
Parameters
-
name: the name/title of the command -
icon: the icon for the command -
ev: the even handler
Returns
a newly created Command instance
-
-
addCommandToRightSideMenu
Adds a Command to the right side navigation menu (it requires a permanent sidemenu or an onTop mode sidemenu, otherwise it does nothing)
Parameters
-
name: the name/title of the command -
icon: the icon for the command -
ev: the even handler
Returns
a newly created Command instance
-
-
addComponentToSideMenu
Adds a Component to the left or right side navigation menu, according to the state of RTL.
Parameters
cmp: c Component to be added to the menu
-
addComponentToSideMenu
This method is responsible to add a Component to the left or right side navigation panel according to the state of RTL.
Parameters
-
menu: @param menu the Menu Container that was created in the constructSideNavigationComponent() method -
cmp: the Component to add to the side menu
-
-
addComponentToSideMenu
Adds a Component to the left or right side navigation menu, according to the state of RTL. The Component is added to the navigation menu and the command gets the events once the Component is being pressed.
Parameters
-
cmp: c Component to be added to the menu -
cmd: a Command to handle the events
-
-
addMaterialCommandToLeftSideMenu
Adds a Command to the left side navigation menu with a material design icon reference
com.codename1.ui.FontImage.Parameters
-
name: the name/title of the command -
icon: the icon for the command -
ev: the even handler
Returns
a newly created Command instance
-
-
addMaterialCommandToRightSideMenu
Adds a Command to the right side navigation menu with a material design icon reference
com.codename1.ui.FontImage(it requires a permanent sidemenu or an onTop mode sidemenu, otherwise it does nothing).Parameters
-
name: the name/title of the command -
icon: the icon for the command -
ev: the even handler
Returns
a newly created Command instance
-
-
addMaterialCommandToSideMenu
Adds a Command to the left or right side navigation menu (according to the state of RTL) with a material design icon reference
com.codename1.ui.FontImage.Parameters
-
name: the name/title of the command -
icon: the icon for the command -
size: size in millimeters for the icon -
ev: the even handler
Returns
a newly created Command instance
-
-
addMaterialCommandToSideMenu
Adds a Command to the left or right side navigation menu (according to the state of RTL) with a material design icon reference
com.codename1.ui.FontImage.Parameters
-
name: the name/title of the command -
icon: the icon for the command -
ev: the even handler
Returns
a newly created Command instance
-
-
addMaterialCommandToLeftSideMenu
public Command addMaterialCommandToLeftSideMenu(String name, char icon, float size, ActionListener ev) Adds a Command to the left side navigation menu with a material design icon reference
com.codename1.ui.FontImage.Parameters
-
name: the name/title of the command -
icon: the icon for the command -
size: size in millimeters for the icon -
ev: the even handler
Returns
a newly created Command instance
-
-
addMaterialCommandToRightSideMenu
public Command addMaterialCommandToRightSideMenu(String name, char icon, float size, ActionListener ev) Adds a Command to the right side navigation menu with a material design icon reference
com.codename1.ui.FontImage(it requires a permanent sidemenu or an onTop mode sidemenu, otherwise it does nothing).Parameters
-
name: the name/title of the command -
icon: the icon for the command -
size: size in millimeters for the icon -
ev: the even handler
Returns
a newly created Command instance
-
-
addMaterialCommandToRightBar
Adds a Command to the TitleArea on the right side with a material design icon reference
com.codename1.ui.FontImage.Parameters
-
name: the name/title of the command -
icon: the icon for the command -
ev: the even handler
Returns
a newly created Command instance
-
-
addMaterialCommandToRightBar
Adds a Command to the TitleArea on the right side with a material design icon reference
com.codename1.ui.FontImage.Parameters
-
name: the name/title of the command -
icon: the icon for the command -
size: size of the icon in millimeters -
ev: the even handler
Returns
a newly created Command instance
-
-
addMaterialCommandToLeftBar
Adds a Command to the TitleArea on the left side with a material design icon reference
com.codename1.ui.FontImage.Parameters
-
name: the name/title of the command -
icon: the icon for the command -
ev: the even handler
Returns
a newly created Command instance
-
-
addMaterialCommandToLeftBar
Adds a Command to the TitleArea on the left side with a material design icon reference
com.codename1.ui.FontImage.Parameters
-
name: the name/title of the command -
icon: the icon for the command -
size: size in millimeters for the icon -
ev: the even handler
Returns
a newly created Command instance
-
-
addMaterialCommandToOverflowMenu
Adds a Command to the overflow menu with a material design icon reference
com.codename1.ui.FontImage.Parameters
-
name: the name/title of the command -
icon: the icon for the command -
ev: the even handler
Returns
a newly created Command instance
-
-
addMaterialCommandToOverflowMenu
public Command addMaterialCommandToOverflowMenu(String name, char icon, float size, ActionListener ev) Adds a Command to the overflow menu with a material design icon reference
com.codename1.ui.FontImage.Parameters
-
name: the name/title of the command -
icon: the icon for the command -
size: size in millimeters for the icon -
ev: the even handler
Returns
a newly created Command instance
-
-
addCommandToSideMenu
Adds a Command to the left or right side navigation menu according to the state of RTL.
Parameters
cmd: a Command
-
addCommandToLeftSideMenu
Adds a Command to the left side navigation menu
Parameters
cmd: a Command
-
addCommandToRightSideMenu
Adds a Command to the right side navigation menu (it requires a permanent sidemenu or an onTop mode sidemenu, otherwise it does nothing).
Parameters
cmd: a Command
-
getLeftSideMenuButton
Allows runtime manipulation of the side menu button, notice this will only work after the menu was created
Returns
a button or null if the menu isn't there yet
-
getRightSideMenuButton
Allows runtime manipulation of the side menu button, notice this will only work after the menu was created
Returns
a button or null if the menu isn't there yet
-
getOverflowButton
Allows runtime manipulation of the overflow button, notice this will only work after the menu was created
Returns
a button or null if the menu isn't there yet
-
setComponentToSideMenuSouth
Places a component in the south portion (bottom) of the left side menu. Notice this only works with on-top side menu and the permanent side menu. Setting this value to null will remove the existing component. Only one component can be placed in the south but it can be a container that includes many components
Parameters
sidemenuSouthComponent: @param sidemenuSouthComponent the new component to place in the south or null to remove the current component
-
setComponentToRightSideMenuSouth
Places a component in the south portion (bottom) of the right side menu. Notice this only works with on-top side menu and the permanent side menu. Setting this value to null will remove the existing component. Only one component can be placed in the south but it can be a container that includes many components
Parameters
sidemenuSouthComponent: @param sidemenuSouthComponent the new component to place in the south or null to remove the current component
-
addComponentToLeftSideMenu
Adds a Component to the left side navigation menu. The Component is added to the navigation menu and the command gets the events once the Component is being pressed.
Parameters
-
cmp: c Component to be added to the menu -
cmd: a Command to handle the events
-
-
addComponentToRightSideMenu
Adds a Component to the right side navigation menu (it requires a permanent sidemenu or an onTop sidemenu, otherwise it does nothing). The Component is added to the navigation menu and the command gets the events once the Component is being pressed.
Parameters
-
cmp: c Component to be added to the menu -
cmd: a Command to handle the events
-
-
addComponentToLeftSideMenu
Adds a Component to the left side navigation menu.
Parameters
cmp: c Component to be added to the menu
-
addComponentToRightSideMenu
Adds a Component to the right side navigation menu (it requires a permanent sidemenu or an onTop sidemenu, otherwise it does nothing).
Parameters
cmp: c Component to be added to the menu
-
findCommandComponent
-
addCommandToRightBar
Adds a Command to the TitleArea on the right side.
Parameters
-
name: the name/title of the command -
icon: the icon for the command -
ev: the even handler
Returns
a newly created Command instance
-
-
removeCommand
Removes a Command from the MenuBar
Parameters
cmd: Command to remove
-
addCommandToRightBar
Adds a Command to the TitleArea on the right side.
Parameters
cmd: a Command
-
addCommandToLeftBar
Adds a Command to the TitleArea on the left side.
Parameters
-
name: the name/title of the command -
icon: the icon for the command -
ev: the even handler
Returns
a newly created Command instance
-
-
addCommandToLeftBar
Adds a Command to the TitleArea on the left side.
Parameters
cmd: a Command
-
getRightBarCommands
-
getLeftBarCommands
-
getMenuBar
Returns the associated SideMenuBar object of this Toolbar.
Returns
the associated SideMenuBar object
-
showOverflowMenu
-
createOverflowCommandList
-
initTitleBarStatus
protected void initTitleBarStatus()Adds a status bar space to the north of the Component, subclasses can override this default behavior. -
setScrollOffUponContentPane
public void setScrollOffUponContentPane(boolean scrollOff) Sets the Toolbar to scroll off the screen upon content scroll. This feature can only work if the Form contentPane is scrollableY
Parameters
scrollOff: @param scrollOff if true the Toolbar needs to scroll off the screen when the Form ContentPane is scrolled
-
hideToolbar
public void hideToolbar()Hide the Toolbar if it is currently showing -
showToolbar
public void showToolbar()Show the Toolbar if it is currently not showing -
animate
public boolean animate()Description copied from class:ComponentAllows the animation to reduce "repaint" calls when it returns false. It is called once for every frame. Frames are defined by the
com.codename1.ui.Displayclass.Returns
true if a repaint is desired or false if no repaint is necessary
-
addComponentToLeftSideMenu
This method responsible to add a Component to the left side navigation panel.
Parameters
-
menu: @param menu the Menu Container that was created in the constructSideNavigationComponent() method -
cmp: the Component to add to the side menu
-
-
addComponentToRightSideMenu
This method responsible to add a Component to the right side navigation panel.
Parameters
-
menu: @param menu the Menu Container that was created in the constructSideNavigationComponent() method -
cmp: the Component to add to the side menu
-
-
getSideMenuCommands
-
getRightSideMenuCommands
-
removeOverflowCommand
Removes the given overflow menu command, notice that this has no effect on the menu that is currently showing (if it is currently showing) only on the upcoming iterations.
Parameters
cmd: the command to remove from the overflow
-
setRightSideMenuCmdsAlignedToLeft
public void setRightSideMenuCmdsAlignedToLeft(boolean toLeft) Normally on a right side menu the alignment should be "mirrored" in comparision with the left side menu, also for non-RTL languages: this method allows to change this default behaviour for non-RTL languages, forcing the alignment of the Commands of the right side menu to left. Note that for RTL languages this method does nothing. This method should be called before adding commands to the right side menu.
Parameters
toLeft: false is the default, true changes the alignment.
-