Skip to content

Instantly share code, notes, and snippets.

package com.codename1.test.bgfetch;
import com.codename1.background.BackgroundFetch;
import com.codename1.components.SpanLabel;
import com.codename1.ui.Display;
import com.codename1.ui.Form;
import com.codename1.ui.Dialog;
import com.codename1.ui.Label;
import com.codename1.ui.plaf.UIManager;
@codenameone
codenameone / Accordion.java
Last active July 8, 2020 09:57 — forked from chen-fishbein/Accordion.java
Accordion usage
Form f = new Form("Accordion", new BorderLayout());
Accordion accr = new Accordion();
accr.addContent("Item1", new SpanLabel("The quick brown fox jumps over the lazy dog\n"
+ "The quick brown fox jumps over the lazy dog"));
accr.addContent("Item2", new SpanLabel("The quick brown fox jumps over the lazy dog\n"
+ "The quick brown fox jumps over the lazy dog\n "
+ "The quick brown fox jumps over the lazy dog\n "
+ "The quick brown fox jumps over the lazy dog\n "
+ ""));
Form hi = new Form("ToastBarDemo", BoxLayout.y());
Button basic = new Button("Basic");
Button progress = new Button("Progress");
Button expires = new Button("Expires");
Button delayed = new Button("Delayed");
hi.add(basic).add(progress).add(expires).add(delayed);
basic.addActionListener(e -> {
ToastBar.Status status = ToastBar.getInstance().createStatus();
@codenameone
codenameone / Sample.java
Last active January 15, 2016 17:21 — forked from shannah/Sample.java
A background painter that puts a circle in the background of a component.
Painter p = new Painter(cmp) {
public void paint(Graphics g, Rectangle rect) {
boolean antiAliased = g.isAntiAliased();
g.setAntiAliased(true);
int r = Math.min(rect.getWidth(), rect.getHeight())/2;
int x = rect.getX() + rect.getWidth()/2 - r;
int y = rect.getY() + rect.getHeight()/2 - r;
switch (style) {
case CircleButtonStrokedDark:
case CircleButtonStrokedLight: {
@codenameone
codenameone / BGLocationTest.java
Last active April 17, 2016 16:22 — forked from shannah/BGLocationTest.java
Geofence Example
public void showForm() {
Form hi = new Form("Hi World");
hi.addComponent(new Label("Hi World"));
Location loc = new Location();
loc.setLatitude(51.5033630);
loc.setLongitude(-0.1276250);
Geofence gf = new Geofence("test", loc, 100, 100000);