use of com.vaadin.v7.ui.Label in project CodenameOne by codenameone.
the class DeviceCalendarSample method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Calendar", BoxLayout.y());
DeviceCalendar dc = DeviceCalendar.getInstance();
if (dc == null) {
hi.add("Device Calendar is null");
hi.show();
return;
}
if (!dc.hasPermissions()) {
hi.add("No Calendar Access Permission");
hi.show();
return;
}
Collection<String> cals = dc.getCalendars();
if (cals == null || cals.isEmpty()) {
hi.add("No Calendars found on the device");
hi.show();
return;
}
int week = 7 * 24 * 60 * 60000;
Date lastWeek = new Date(System.currentTimeMillis() - week);
Date nextWeek = new Date(System.currentTimeMillis() - week);
for (String s : cals) {
Button b = new Button(s);
b.addActionListener(e -> {
String calId = dc.openCalendar(s, false);
Collection<EventInfo> events = dc.getEvents(calId, lastWeek, nextWeek);
Form f = new Form("Events", BoxLayout.y());
for (EventInfo ei : events) {
f.add(new Label(L10NManager.getInstance().formatDateTimeShort(ei.getStartTime()) + ei.getTitle()));
}
f.getToolbar().setBackCommand("", ee -> hi.showBack());
f.show();
});
hi.add(b);
}
hi.show();
}
use of com.vaadin.v7.ui.Label in project CodenameOne by codenameone.
the class DragFinishedListenerTest3056 method start.
public void start() {
if (current != null) {
current.show();
return;
}
Container cnt = new Container();
Label imageLbl = new Label();
FontImage.setMaterialIcon(imageLbl, FontImage.MATERIAL_3D_ROTATION, 10);
cnt.add(imageLbl);
cnt.add(new Label("Another label in the container"));
imageLbl.setDraggable(true);
boolean isTest = true;
if (!isTest) {
cnt.putClientProperty("isTest", false);
} else {
cnt.putClientProperty("isTest", true);
}
cnt.setLeadComponent(imageLbl);
cnt.setDraggable(true);
imageLbl.addPointerDraggedListener((evt) -> {
System.out.println("in drag");
});
imageLbl.addDragFinishedListener((evt) -> {
System.out.println("Drag finished");
});
Form hi = new Form("Hi World", BoxLayout.y());
hi.add(cnt);
hi.show();
}
use of com.vaadin.v7.ui.Label in project CodenameOne by codenameone.
the class DraggableTabsSample method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Tabs", new BorderLayout());
Tabs t = new Tabs();
t.addTab("T1", new Label("Tab 1"));
t.addTab("T2", new Label("Tab 2"));
t.addTab("T3", new Label("Tab 3"));
t.addTab("T4", new Label("Tab 4"));
Container tabsC = t.getTabsContainer();
tabsC.setDropTarget(true);
for (Component c : tabsC) {
c.setDraggable(true);
c.addDropListener(e -> {
e.consume();
Component dragged = c;
int x = e.getX();
int y = e.getY();
int i = tabsC.getComponentIndex(dragged);
if (i > -1) {
Component dest = tabsC.getComponentAt(x, y);
if (dest != dragged) {
Component source = t.getTabComponentAt(i);
int destIndex = tabsC.getComponentIndex(dest);
if (destIndex > -1 && destIndex != i) {
String title = t.getTabTitle(i);
t.removeTabAt(i);
if (destIndex > i) {
t.insertTab(title, null, source, destIndex - 1);
} else {
t.insertTab(title, null, source, destIndex);
}
}
}
tabsC.animateLayout(400);
}
});
}
hi.add(CENTER, t);
hi.show();
}
use of com.vaadin.v7.ui.Label in project CodenameOne by codenameone.
the class ButtonLongPointerPress method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", BoxLayout.y());
hi.add(new Label("Hi World"));
Button b = new Button("Long Press Me") {
@Override
public void longPointerPress(int x, int y) {
System.out.println("Long pointer press received");
}
};
hi.add(b);
hi.show();
}
use of com.vaadin.v7.ui.Label in project CodenameOne by codenameone.
the class VideoTransition method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", new BorderLayout());
Button swap = new Button("Swap");
Container theCnt = new Container(new LayeredLayout());
Label imageLabel = new Label();
$(imageLabel).selectAllStyles().setBgColor(0).setBgTransparency(255);
MediaPlayer mediaPlayer = new MediaPlayer();
$(mediaPlayer).selectAllStyles().setBgColor(0).setBgTransparency(255);
swap.addActionListener(e -> {
if (image == null) {
image = Util.downloadImageToStorage("https://www.codenameone.com/img/uber-skin.png", "uber-skin.png").get();
imageLabel.setIcon(image.scaled(CN.getDisplayWidth(), CN.getDisplayHeight()));
}
if (!mediaLoaded) {
try {
mediaPlayer.setDataSource("https://upload.wikimedia.org/wikipedia/commons/b/b3/Big_Buck_Bunny_Trailer_400p.ogv", null);
} catch (IOException ex) {
Log.e(ex);
}
mediaLoaded = true;
}
if (theCnt.getComponentCount() == 0) {
theCnt.add(mediaPlayer);
mediaPlayer.getMedia().play();
hi.revalidateWithAnimationSafety();
} else if (theCnt.contains(mediaPlayer) && !theCnt.contains(imageLabel)) {
imageLabel.getAllStyles().setOpacity(0);
imageLabel.getAllStyles().setBgTransparency(0);
theCnt.add(imageLabel);
theCnt.revalidateWithAnimationSafety();
fadeIn(imageLabel, 500).ready(res -> {
mediaPlayer.getMedia().pause();
mediaPlayer.remove();
hi.revalidateWithAnimationSafety();
});
} else if (theCnt.contains(imageLabel) && !theCnt.contains(mediaPlayer)) {
theCnt.addComponent(0, mediaPlayer);
mediaPlayer.getMedia().play();
fadeOut(imageLabel, 500).ready(res -> {
imageLabel.remove();
theCnt.revalidateWithAnimationSafety();
});
}
});
hi.add(BorderLayout.NORTH, swap);
hi.add(BorderLayout.CENTER, theCnt);
hi.show();
}
Aggregations