Skip to content

Instantly share code, notes, and snippets.

@codenameone
Created November 5, 2017 13:00
Show Gist options
  • Save codenameone/5a28c7944aeab7d8ae6b26dc81690238 to your computer and use it in GitHub Desktop.
Save codenameone/5a28c7944aeab7d8ae6b26dc81690238 to your computer and use it in GitHub Desktop.
TextModeLayout tl = new TextModeLayout(3, 2);
Form f = new Form("Pixel Perfect", tl);
TextComponent title = new TextComponent().label("Title");
TextComponent price = new TextComponent().label("Price");
TextComponent location = new TextComponent().label("Location");
PickerComponent date = PickerComponent.createDate(new Date()).label("Date");
TextComponent description = new TextComponent().label("Description").multiline(true);
Validator val = new Validator();
val.addConstraint(title, new LengthConstraint(2));
val.addConstraint(price, new NumericConstraint(true));
f.add(tl.createConstraint().widthPercentage(60), title);
f.add(tl.createConstraint().widthPercentage(40), date);
f.add(location);
f.add(price);
f.add(tl.createConstraint().horizontalSpan(2), description);
f.setEditOnShow(title.getField());
f.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment