Skip to content

Instantly share code, notes, and snippets.

@codenameone
codenameone / FlowLayoutSample.java
Last active January 27, 2016 21:12
Terse syntax for Codename One flow layout creation
Container flowLayout = FlowLayout.encloseIn(new Label("First"),
new Label("Second"),
new Label("Third"),
new Label("Fourth"),
new Label("Fifth"));
@codenameone
codenameone / BoxLayoutYSample.java
Created January 27, 2016 13:45
Simple usage of the box layout Y API of Codename One
Form hi = new Form("Box Y Layout", new BoxLayout(BoxLayout.Y_AXIS));
hi.add(new Label("First")).
add(new Label("Second")).
add(new Label("Third")).
add(new Label("Fourth")).
add(new Label("Fifth"));
@codenameone
codenameone / BoxLayoutXTerseSyntaxSample.java
Created January 27, 2016 13:51
Sample of the terse box layout syntax of the box layout X Codename One API
Container box = BoxLayout.encloseX(new Label("First"),
new Label("Second"),
new Label("Third"),
new Label("Fourth"),
new Label("Fifth")));
@codenameone
codenameone / GridLayout2x2Sample.java
Created January 27, 2016 21:02
Sample of the grid layout from Codename One
Form hi = new Form("Grid Layout 2x2", new GridLayout(2, 2));
hi.add(new Label("First")).
add(new Label("Second")).
add(new Label("Third")).
add(new Label("Fourth")).
add(new Label("Fifth"));
@codenameone
codenameone / GridLayoutAutofitTerseSample.java
Created January 27, 2016 21:13
Sample of GridLayout usage in Codename One for terse syntax
GridLayout.encloseIn(new Label("First"),
new Label("Second"),
new Label("Third"),
new Label("Fourth"),
new Label("Fifth")));
@codenameone
codenameone / TableLayoutSample.java
Created January 28, 2016 09:14
Simple sample of the Codename One table layout
Form hi = new Form("Table Layout 2x2", new TableLayout(2, 2));
hi.add(new Label("First")).
add(new Label("Second")).
add(new Label("Third")).
add(new Label("Fourth")).
add(new Label("Fifth"));
hi.show();
@codenameone
codenameone / TableLayoutTerseSyntaxSample.java
Created January 28, 2016 09:19
Sample of the Codename One TableLayout using the terse syntax calls
Container tl = TableLayout.encloseIn(2, new Label("First"),
new Label("Second"),
new Label("Third"),
new Label("Fourth"),
new Label("Fifth")));
@codenameone
codenameone / TableLayoutConstraintExample.java
Created January 28, 2016 12:47
A more elaborate example that shows off complex Codename One TableLayout usage
TableLayout tl = new TableLayout(2, 3);
Form hi = new Form("Table Layout Cons", tl);
hi.setScrollable(false);
hi.add(tl.createConstraint().
widthPercentage(20),
new Label("AAA")).
add(tl.createConstraint().
horizontalSpan(2).
heightPercentage(80).
@codenameone
codenameone / LayeredLayoutSample.java
Created January 29, 2016 20:38
A rather elaborate sampleto show off the layered layout Codename One API
Form hi = new Form("Layered Layout");
int w = Math.min(Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight());
Button settingsLabel = new Button("");
Style settingsStyle = settingsLabel.getAllStyles();
settingsStyle.setFgColor(0xff);
settingsStyle.setBorder(null);
settingsStyle.setBgColor(0xff00);
settingsStyle.setBgTransparency(255);
settingsStyle.setFont(settingsLabel.getUnselectedStyle().getFont().derive(w / 3, Font.STYLE_PLAIN));
FontImage.setMaterialIcon(settingsLabel, FontImage.MATERIAL_SETTINGS);
@codenameone
codenameone / GroupLayoutSample.java
Created January 30, 2016 21:40
Sample using the group layout in Codename One generated by the NetBeans GUI builder
Form hi = new Form("GroupLayout");
Label label1 = new Label();
Label label2 = new Label();
Label label3 = new Label();
Label label4 = new Label();
Label label5 = new Label();
Label label6 = new Label();
Label label7 = new Label();