Last active
July 8, 2020 09:57
-
-
Save codenameone/ba6fdc5f841b083e13e9 to your computer and use it in GitHub Desktop.
Demonstrates the unlayout API in Codename One layout animations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Form hi = new Form("Layout Animations", new BoxLayout(BoxLayout.Y_AXIS)); | |
Button fall = new Button("Fall"); | |
fall.addActionListener((e) -> { | |
if(hi.getContentPane().getComponentCount() == 1) { | |
fall.setText("Rise"); | |
for(int iter = 0 ; iter < 10 ; iter++) { | |
Label b = new Label ("Label " + iter); | |
b.setWidth(fall.getWidth()); | |
b.setHeight(fall.getHeight()); | |
b.setY(-fall.getHeight()); | |
hi.add(b); | |
} | |
hi.getContentPane().animateLayout(20000); | |
} else { | |
fall.setText("Fall"); | |
for(int iter = 1 ; iter < hi.getContentPane().getComponentCount() ; iter++) { | |
Component c = hi.getContentPane().getComponentAt(iter); | |
c.setY(-fall.getHeight()); | |
} | |
hi.getContentPane().animateUnlayoutAndWait(20000, 255); | |
hi.removeAll(); | |
hi.add(fall); | |
hi.revalidate(); | |
// the following lines demonstrate the async version of the last few lines above | |
/*hi.getContentPane().animateUnlayout(20000, 255, () -> { | |
hi.removeAll(); | |
hi.add(fall); | |
hi.revalidate(); | |
});*/ | |
} | |
}); | |
hi.add(fall); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample usage code for animateUnlayout
From the Codename One project