Search in sources :

Example 26 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class GoogleLoginSample method showContactsForm.

public void showContactsForm(UserData data) {
    Form f = new Form("Contact Info");
    f.setToolbar(new Toolbar());
    f.getToolbar().setTitle("Contact Info");
    Form prev = CN.getCurrentForm();
    if (prev != null) {
        f.getToolbar().setBackCommand(new Command("Back") {

            public void actionPerformed(ActionEvent evt) {
                prev.show();
            }
        });
    }
    f.add(new Label("You are logged in as " + fullName));
    Button logout = new Button("Log out");
    logout.addActionListener(e -> {
        GoogleConnect.getInstance().doLogout();
        Preferences.set(tokenPrefix + "tokenExpires", -1);
        Preferences.set(tokenPrefix + "token", (String) null);
        showLoginForm();
    });
    f.add(logout);
    f.show();
}
Also used : Form(com.codename1.ui.Form) Command(com.codename1.ui.Command) Button(com.codename1.ui.Button) ActionEvent(com.codename1.ui.events.ActionEvent) Label(com.codename1.ui.Label) Toolbar(com.codename1.ui.Toolbar)

Example 27 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class GoogleMapsAddMarkerSample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Coord location = new Coord(37.7831, -122.401558);
    Form mapDemo = new Form("Maps", new BorderLayout());
    if (BrowserComponent.isNativeBrowserSupported()) {
        System.out.println("Browser Component Supported");
        MapContainer mc = new MapContainer(JS_API_KEY);
        // Add buttons at top to provide an offset so we can test event
        // coordinates properly.
        mapDemo.add(BorderLayout.NORTH, BoxLayout.encloseY(new Button("Button 1"), new Button("Button 2")));
        mapDemo.add(BorderLayout.CENTER, BorderLayout.centerEastWest(mc, null, new Button("Button 5")));
        Coord moscone = new Coord(37.7831, -122.401558);
        mc.zoom(moscone, 5);
        mc.setCameraPosition(moscone);
        mc.addTapListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent evt) {
                // Point of the screen where the user pressed
                int x = evt.getX();
                int y = evt.getY();
                // I get the coordinates from the point of the screen
                Coord coord = mc.getCoordAtPosition(x, y);
                // I create the marker, with a style
                Style s = new Style();
                s.setFgColor(0xff0000);
                s.setBgTransparency(0);
                FontImage markerImg = FontImage.createMaterial(FontImage.MATERIAL_PLACE, s);
                EncodedImage icon = EncodedImage.createFromImage(markerImg, false);
                mc.addMarker(icon, coord, "My position", null, null);
                mc.zoom(coord, 15);
            }
        });
    // mc.setShowMyLocation(true);
    } else {
        // iOS Screenshot process...
        mapDemo.add(new Label("Loading, please wait...."));
    }
    mapDemo.show();
}
Also used : Coord(com.codename1.maps.Coord) BorderLayout(com.codename1.ui.layouts.BorderLayout) ActionListener(com.codename1.ui.events.ActionListener) Form(com.codename1.ui.Form) Button(com.codename1.ui.Button) ActionEvent(com.codename1.ui.events.ActionEvent) Label(com.codename1.ui.Label) Style(com.codename1.ui.plaf.Style) FontImage(com.codename1.ui.FontImage) EncodedImage(com.codename1.ui.EncodedImage) MapContainer(com.codename1.googlemaps.MapContainer)

Example 28 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class GradientTest method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    hi.getContentPane().setUIID("Gradient");
    hi.add(new Label("Hi World"));
    hi.show();
}
Also used : Form(com.codename1.ui.Form) Label(com.codename1.ui.Label)

Example 29 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class AutocompleteSample2788 method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Popup test", BorderLayout.absolute());
    AutoCompleteTextField autocomplete = new AutoCompleteTextField("1", "2", "3", "11", "22", "33");
    autocomplete.setMinimumLength(1);
    Button tapMe = new Button("Tap me leaving the popup opened");
    tapMe.addActionListener(l -> {
        hi.replace(autocomplete, new Label("other content"), null);
        hi.revalidate();
    });
    hi.add(BorderLayout.CENTER, autocomplete);
    hi.add(BorderLayout.NORTH, tapMe);
    hi.show();
}
Also used : AutoCompleteTextField(com.codename1.ui.AutoCompleteTextField) Form(com.codename1.ui.Form) Button(com.codename1.ui.Button) Label(com.codename1.ui.Label)

Example 30 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class BindButtonStateTest method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    Button button1 = new Button("Button 1");
    button1.setIconUIID("GrayIcon");
    // button1.getIconStyleComponent().getStyle().setFgColor(0xff0000);
    FontImage.setIcon(button1, FontImage.MATERIAL_INBOX, -1);
    Button button2 = new Button("Button 2");
    button2.bindStateTo(button1);
    hi.add(new Label("Hi World"));
    hi.addAll(button1, button2);
    hi.show();
}
Also used : Form(com.codename1.ui.Form) Button(com.codename1.ui.Button) Label(com.codename1.ui.Label)

Aggregations

Label (com.codename1.ui.Label)129 Form (com.codename1.ui.Form)95 Button (com.codename1.ui.Button)50 BorderLayout (com.codename1.ui.layouts.BorderLayout)50 Container (com.codename1.ui.Container)49 Component (com.codename1.ui.Component)27 SpanLabel (com.codename1.components.SpanLabel)26 Style (com.codename1.ui.plaf.Style)24 BoxLayout (com.codename1.ui.layouts.BoxLayout)19 TextArea (com.codename1.ui.TextArea)18 ActionEvent (com.codename1.ui.events.ActionEvent)18 IOException (java.io.IOException)18 Image (com.codename1.ui.Image)17 Dimension (com.codename1.ui.geom.Dimension)16 TextField (com.codename1.ui.TextField)15 ActionListener (com.codename1.ui.events.ActionListener)15 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)15 Toolbar (com.codename1.ui.Toolbar)13 FlowLayout (com.codename1.ui.layouts.FlowLayout)12 EncodedImage (com.codename1.ui.EncodedImage)11