Skip to content

Instantly share code, notes, and snippets.

@jsfan3
Created November 22, 2021 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsfan3/67074c6684b0ee711c6f6d950cdefb57 to your computer and use it in GitHub Desktop.
Save jsfan3/67074c6684b0ee711c6f6d950cdefb57 to your computer and use it in GitHub Desktop.
Codename One - Test Tabs swipe on X-Axis and Y-Axis
Form hi = new Form("Test swipe on tabs", BorderLayout.absolute());
Tabs tabs = new Tabs();
ButtonGroup btnGroup = new ButtonGroup();
Button swipeXBtn = RadioButton.createToggle("Swipe on X-Axis", btnGroup);
Button swipeYBtn = RadioButton.createToggle("Swipe on Y-Axis", btnGroup);
btnGroup.setSelected(0);
swipeXBtn.addActionListener(l -> {
tabs.setSwipeOnXAxis(true);
});
swipeYBtn.addActionListener(l -> {
tabs.setSwipeOnXAxis(false);
});
hi.add(BorderLayout.NORTH, GridLayout.encloseIn(2, swipeXBtn, swipeYBtn));
//tabs.hideTabs();
hi.add(BorderLayout.CENTER, tabs);
List<Component> cards = new ArrayList<>();
for (int i=0; i<20; i++) {
Container card = new Container(BoxLayout.y());
card.getAllStyles().setBorder(Border.createLineBorder(CN.convertToPixels(1)/5, 0));
card.addAll(FlowLayout.encloseCenter(new Label(FontImage.createMaterial(FontImage.MATERIAL_PERSON, "Label", 50.0f))), new Label("Card " + i));
cards.add(card);
tabs.addTab("tab " + i, card);
}
hi.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment