Java Code Examples for com.codename1.ui.Form#revalidate()
The following examples show how to use
com.codename1.ui.Form#revalidate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContainerList.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
private void updateComponentCount() { int cc = getComponentCount(); int modelCount = model.getSize(); if(cc != modelCount) { if(cc < modelCount) { for(int iter = cc ; iter < modelCount ; iter++) { addComponent(new Entry(iter)); } } else { while(getComponentCount() > modelCount) { removeComponent(getComponentAt(getComponentCount() - 1)); } } Form f = getComponentForm(); if(f != null) { f.revalidate(); } } }
Example 2
Source File: Picker.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
private void restoreContentPane() { Form f = getComponentForm(); if (tmpContentPaneMarginUnit != null && f != null) { Container contentPane = f.getContentPane(); Style style = contentPane.getStyle(); style.setMarginUnit(tmpContentPaneMarginUnit); style.setMarginBottom(tmpContentPaneBottomMargin); tmpContentPaneMarginUnit=null; f.revalidate(); // If we remove the margin, it sometimes leaves the content pane // in a negative scroll position - which leaves a gap at the top. // Simulating a drag will trigger tensile drag to push the content // back up to the top. // See https://github.com/codenameone/CodenameOne/issues/2476 if (f != null && f.getContentPane() != null && f.getContentPane().getScrollY() < 0) { f.getContentPane().pointerPressed(100, 100); f.getContentPane().pointerDragged(100, 100); f.getContentPane().pointerReleased(100, 100); } } }
Example 3
Source File: NestedFormWithSwipeableTabsTest2776.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public void start() { if(current != null){ current.show(); return; } Form outer = new Form("", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_SCALE)); outer.getToolbar().hideToolbar(); Form inner = new Form("Tabs", new BorderLayout()); Container layeredPane1 = inner.getLayeredPane(NestedFormWithSwipeableTabsTest2776.class, 1); layeredPane1.setLayout(new BorderLayout()); Container layeredPane2 = inner.getLayeredPane(AnotherClass.class, 2); layeredPane2.setLayout(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE)); Tabs tab = new Tabs(); tab.addTab("Tab1", new SpanLabel("Tab 1")); tab.addTab("Tab2", new SpanLabel("Tab 2")); inner.add(BorderLayout.CENTER, tab); outer.add(BorderLayout.CENTER, inner); outer.revalidate(); outer.show(); }
Example 4
Source File: SocialChat.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
private void createMorphEffect(Label titleLabel) { // animate the components out of the previous form if we are coming in from the login form Form parent = Display.getInstance().getCurrent(); if(parent.getUIID().equals("MainForm")) { for(Component cmp : parent.getContentPane()) { cmp.setX(parent.getWidth()); } // moves all the components outside of the content pane to the right while fading them out over 400ms parent.getContentPane().animateUnlayoutAndWait(400, 0); parent.getContentPane().removeAll(); // we can't mutate a form into a component in another form so we need to convert the background to an image and then morph that // this is especially easy since we already removed all the components Label dummy = new Label(); dummy.setShowEvenIfBlank(true); dummy.setUIID("Container"); dummy.setUnselectedStyle(new Style(parent.getUnselectedStyle())); parent.setUIID("Form"); // special case to remove status bar on iOS 7 parent.getTitleArea().removeAll(); parent.setLayout(new BorderLayout()); parent.addComponent(BorderLayout.CENTER, dummy); parent.revalidate(); // animate the main panel to the new location at the top title area of the screen dummy.setName("fullScreen"); titleLabel.setName("titleImage"); parent.setTransitionOutAnimator(MorphTransition.create(1100).morph("fullScreen", "titleImage")); } }
Example 5
Source File: Themes.java From codenameone-demos with GNU General Public License v2.0 | 4 votes |
private void refreshTheme(Form parentForm) { Form c = Display.getInstance().getCurrent(); c.refreshTheme(); parentForm.refreshTheme(); parentForm.revalidate(); }
Example 6
Source File: KitchenSink.java From codenameone-demos with GNU General Public License v2.0 | 4 votes |
private void showSplashAnimation() { Form splash = new Form(); splash.setUIID("Splash"); splash.getContentPane().setUIID("Container"); splash.getTitleArea().setUIID("Container"); BorderLayout border = new BorderLayout(); border.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE); splash.setLayout(border); splash.setScrollable(false); Label title = new Label("Kitchen Sink Demo"); title.setUIID("SplashTitle"); Label subtitle = new Label("By Codename One"); subtitle.setUIID("SplashSubTitle"); splash.addComponent(BorderLayout.NORTH, title); splash.addComponent(BorderLayout.SOUTH, subtitle); Label beaker = new Label(res.getImage("beaker.png")); final Label beakerLogo = new Label(res.getImage("beaker_logo.png")); beakerLogo.setVisible(false); Container layeredLayout = new Container(new LayeredLayout()); splash.addComponent(BorderLayout.CENTER, layeredLayout); layeredLayout.addComponent(beaker); final Container logoParent = new Container(new BorderLayout()); layeredLayout.addComponent(logoParent); logoParent.addComponent(BorderLayout.CENTER, beakerLogo); splash.revalidate(); Display.getInstance().callSerially(new Runnable() { public void run() { beakerLogo.setVisible(true); beakerLogo.setX(0); beakerLogo.setY(0); beakerLogo.setWidth(3); beakerLogo.setHeight(3); logoParent.setShouldCalcPreferredSize(true); logoParent.animateLayoutFade(2000, 0); } }); splash.show(); splash.setTransitionOutAnimator(CommonTransitions.createFastSlide(CommonTransitions.SLIDE_VERTICAL, true, 300)); new UITimer(new Runnable() { public void run() { showMainUI(); } }).schedule(2500, false, splash); }
Example 7
Source File: TestComponent.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
boolean runOwnerTests() throws Exception { log("Running ownerTests"); Container cnt = new Container(); Button b2 = new Button(); assertTrue(!cnt.isOwnedBy(b2), "cnt is not owned by b2"); assertTrue(!b2.isOwnedBy(cnt), "b2 is not owned by cn1"); cnt.add(b2); assertTrue(!b2.isOwnedBy(cnt), "button should not be owned by cn1 even though it is a child"); b2.setOwner(cnt); assertTrue(b2.isOwnedBy(cnt), "Button should be owned by container"); b2.setOwner(null); assertTrue(!b2.isOwnedBy(cnt), "Button should no longer be owned by container"); Container c2 = new Container(); c2.setOwner(cnt); assertTrue(c2.isOwnedBy(cnt), "c2 should be owned by cnt"); b2.remove(); c2.add(b2); assertTrue(b2.isOwnedBy(cnt), "b2 should be owned by cnt because its parent is owned by cnt"); b2.remove(); assertTrue(!b2.isOwnedBy(cnt), "b2 should no longer be owned by cnt"); b2.setOwner(c2); assertTrue(b2.isOwnedBy(cnt), "b2 should be owned by cnt because of the owner hierarchy through c2"); Form f1 = new Form("Test Form", BoxLayout.y()); f1.setName("TestForm"); f1.show(); waitForFormName("TestForm"); //waitFor(2000); Button b3 = new Button("B3"); Button b4 = new Button("B4"); f1.add(b3).add(b4); f1.revalidate(); //System.out.println(c(b3)); //System.out.println(b3.contains(c(b3).getX(), c(b3).getY())); //System.out.println("Absx="+b3.getAbsoluteX()+", absy="+b3.getAbsoluteY()+", w="+b3.getWidth()+", h="+b3.getHeight()); assertTrue(b3.contains(c(b3).getX(), c(b3).getY())); assertTrue(!b3.contains(c(b4).getX(), c(b4).getY())); assertTrue(b3.containsOrOwns(c(b3).getX(), c(b3).getY())); assertTrue(!b3.containsOrOwns(c(b4).getX(), c(b4).getY())); b4.setOwner(b3); assertTrue(b3.containsOrOwns(c(b4).getX(), c(b4).getY())); Container c4 = new Container(BoxLayout.x()); Button b5 = new Button("B5"); c4.add(b5); f1.add(c4); f1.revalidate(); assertTrue(!b3.containsOrOwns(c(b5).getX(), c(b5).getY())); c4.setOwner(b3); //System.out.println("Component: "+f1.getComponentAt(c(b5).getX(), c(b5).getY())); assertTrue(b3.containsOrOwns(c(b5).getX(), c(b5).getY())); Container c5 = new Container(); b3.remove(); c5.add(b3); f1.add(c5); f1.revalidate(); assertTrue(c5.containsOrOwns(c(b5).getX(), c(b5).getY())); return true; }