Skip to content

Instantly share code, notes, and snippets.

View chen-fishbein's full-sized avatar

Chen Fishbein chen-fishbein

View GitHub Profile
@codenameone
codenameone / CanExecuteSample.java
Last active July 8, 2020 09:57
Demonstrates the Codname One canExecute and Execute API's of Display
Boolean can = Display.getInstance().canExecute("imdb:///find?q=godfather");
if(can != null && can) {
Display.getInstance().execute("imdb:///find?q=godfather");
} else {
Display.getInstance().execute("http://www.imdb.com");
}
@codenameone
codenameone / ShapeSample.java
Created March 17, 2016 05:43
Usage of the Shape drawing API in Codename One and GeneralPath
Form hi = new Form("Shape");
// We create a 50 x 100 shape, this is arbitrary since we can scale it easily
GeneralPath path = new GeneralPath();
path.moveTo(20,0);
path.lineTo(30, 0);
path.lineTo(30, 100);
path.lineTo(20, 100);
path.lineTo(20, 15);
path.lineTo(5, 40);
@codenameone
codenameone / FontCatalog.java
Last active July 8, 2020 09:57
A sample for Font usage in Codename One that goes over all of the "big pieces" in Codename One fonts to display a large catalog of "whats available"
private Label createForFont(Font fnt, String s) {
Label l = new Label(s);
l.getUnselectedStyle().setFont(fnt);
return l;
}
public void showForm() {
GridLayout gr = new GridLayout(5);
gr.setAutoFit(true);
Form hi = new Form("Fonts", gr);
@codenameone
codenameone / FloatingHintSample.java
Created March 17, 2016 14:59
Codename Ones FloatingHint animates the text components hint label into a component title on top while editing
Form hi = new Form("Floating Hint", BoxLayout.y());
TextField first = new TextField("", "First Field");
TextField second = new TextField("", "Second Field");
hi.add(new FloatingHint(first)).
add(new FloatingHint(second)).
add(new Button("Go"));
hi.show();
@codenameone
codenameone / BubbleSample.java
Created March 21, 2016 18:01
Sample code for the new BubbleTransition effect in Codename One
Form hi = new Form("Bubble");
Button showBubble = new Button("+");
showBubble.setName("BubbleButton");
Style buttonStyle = showBubble.getAllStyles();
buttonStyle.setBorder(Border.createEmpty());
buttonStyle.setFgColor(0xffffff);
buttonStyle.setBgPainter((g, rect) -> {
g.setColor(0xff);
int actualWidth = rect.getWidth();
int actualHeight = rect.getHeight();
@codenameone
codenameone / ShapedClippingSample.java
Last active July 8, 2020 09:57
Demonstration of shaped clipping effects in Codename One
Image duke = null;
try {
// duke.png is just the default Codename One icon copied into place
duke = Image.createImage("/duke.png");
} catch(IOException err) {
Log.e(err);
}
final Image finalDuke = duke;
Form hi = new Form("Shape Clip");