Search in sources :

Example 26 with CheckBox

use of com.vaadin.v7.ui.CheckBox in project CodenameOne by codenameone.

the class MultiButton method setCheckBox.

/**
 * Turns the multi-button into a checkbox multi-button
 *
 * @param b true for a checkbox multi-button
 */
public void setCheckBox(boolean b) {
    if (b != isCheckBox()) {
        Container par = emblem.getParent();
        Button old = emblem;
        if (b) {
            emblem = new CheckBox();
        } else {
            emblem = new Button();
        }
        emblem.setUIID(old.getUIID());
        emblem.setName(old.getName());
        java.util.List actionListeners = (java.util.List) old.getListeners();
        if (actionListeners != null) {
            for (int iter = 0; iter < actionListeners.size(); iter++) {
                emblem.addActionListener((ActionListener) actionListeners.get(iter));
            }
        }
        if (old.getCommand() != null) {
            Image img = old.getIcon();
            emblem.setCommand(old.getCommand());
            emblem.setText("");
            emblem.setIcon(img);
        } else {
            emblem.setText(old.getText());
            if (old.getIcon() != null) {
                emblem.setIcon(old.getIcon());
            }
        }
        par.replace(old, emblem, null);
        setLeadComponent(emblem);
    }
}
Also used : Container(com.codename1.ui.Container) RadioButton(com.codename1.ui.RadioButton) Button(com.codename1.ui.Button) CheckBox(com.codename1.ui.CheckBox) Image(com.codename1.ui.Image)

Example 27 with CheckBox

use of com.vaadin.v7.ui.CheckBox in project CodenameOne by codenameone.

the class OnOffSwitch method initialize.

private void initialize() {
    iosMode = UIManager.getInstance().isThemeConstant("onOffIOSModeBool", false);
    removeAll();
    setFocusable(true);
    if (iosMode) {
        button = null;
        switchMaskImage = UIManager.getInstance().getThemeImageConstant("switchMaskImage");
        switchOnImage = UIManager.getInstance().getThemeImageConstant("switchOnImage");
        switchOffImage = UIManager.getInstance().getThemeImageConstant("switchOffImage");
        noTextMode = UIManager.getInstance().isThemeConstant("noTextModeBool", false);
    } else {
        setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        button = new CheckBox(on);
        button.setToggle(true);
        button.setUIID("Button");
        button.setEndsWith3Points(false);
        button.getUnselectedStyle().setFont(getUnselectedStyle().getFont());
        button.getSelectedStyle().setFont(getSelectedStyle().getFont());
        button.getPressedStyle().setFont(getSelectedStyle().getFont());
        Dimension d = button.getPreferredSize();
        button.setText(off);
        int pw = button.getPreferredW();
        d.setWidth(Math.max(pw, d.getWidth()));
        // prevents the button from growing/shrinking as its states flip
        button.setPreferredSize(d);
        buttonWidth = button.getPreferredW();
        button.setFocusable(false);
        updateButton();
        addComponent(button);
        button.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                flip();
            }
        });
    }
}
Also used : ActionListener(com.codename1.ui.events.ActionListener) CheckBox(com.codename1.ui.CheckBox) ActionEvent(com.codename1.ui.events.ActionEvent) BoxLayout(com.codename1.ui.layouts.BoxLayout) Dimension(com.codename1.ui.geom.Dimension)

Example 28 with CheckBox

use of com.vaadin.v7.ui.CheckBox in project CodenameOne by codenameone.

the class LiveDemo method start.

public void start() {
    Form previewForm = new Form("Preview Theme");
    Toolbar tb = new Toolbar();
    previewForm.setToolbar(tb);
    tb.setTitle("Preview Theme");
    tb.addMaterialCommandToSideMenu("Side Command", FontImage.MATERIAL_HELP, new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            ToastBar.showErrorMessage("Unmapped....");
        }
    });
    tb.addMaterialCommandToOverflowMenu("Overflow Command", FontImage.MATERIAL_HELP, new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            ToastBar.showErrorMessage("Unmapped....");
        }
    });
    tb.addMaterialCommandToRightBar("", FontImage.MATERIAL_HELP, new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            ToastBar.showErrorMessage("Unmapped....");
        }
    });
    previewForm.setLayout(new BorderLayout());
    Container first = new Container(new BoxLayout(BoxLayout.Y_AXIS));
    first.addComponent(new Label("This is a Label"));
    first.addComponent(new Button("This is a Button"));
    MultiButton mb = new MultiButton("This is a MultiButton");
    mb.setTextLine2("Second line of text");
    FontImage.setMaterialIcon(mb, FontImage.MATERIAL_HELP);
    first.addComponent(mb);
    TextField txt = new TextField();
    txt.setHint("This is a TextField");
    first.addComponent(txt);
    first.addComponent(new CheckBox("This is a CheckBox"));
    first.addComponent(FlowLayout.encloseIn(new Label("This is a switch "), new Switch()));
    RadioButton rb1 = new RadioButton("This is a Radio Button 1");
    rb1.setGroup("group");
    first.addComponent(rb1);
    RadioButton rb2 = new RadioButton("This is a Radio Button 2");
    rb2.setGroup("group");
    first.addComponent(rb2);
    final Slider s = new Slider();
    s.setText("50%");
    s.setProgress(50);
    s.setEditable(true);
    s.setRenderPercentageOnTop(true);
    first.addComponent(s);
    Button b1 = new Button("Show a Dialog");
    b1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            Dialog.show("Dialog Title", "Dialog Body", "Ok", "Cancel");
        }
    });
    first.addComponent(b1);
    previewForm.add(BorderLayout.CENTER, first);
    previewForm.show();
}
Also used : Slider(com.codename1.ui.Slider) Form(com.codename1.ui.Form) ActionEvent(com.codename1.ui.events.ActionEvent) BoxLayout(com.codename1.ui.layouts.BoxLayout) Label(com.codename1.ui.Label) RadioButton(com.codename1.ui.RadioButton) Container(com.codename1.ui.Container) ActionListener(com.codename1.ui.events.ActionListener) BorderLayout(com.codename1.ui.layouts.BorderLayout) Switch(com.codename1.components.Switch) RadioButton(com.codename1.ui.RadioButton) Button(com.codename1.ui.Button) MultiButton(com.codename1.components.MultiButton) CheckBox(com.codename1.ui.CheckBox) TextField(com.codename1.ui.TextField) MultiButton(com.codename1.components.MultiButton) Toolbar(com.codename1.ui.Toolbar)

Example 29 with CheckBox

use of com.vaadin.v7.ui.CheckBox in project CodenameOne by codenameone.

the class InterFormContainerSample method start.

public void start() {
    Button sharedButton = new Button("Shared Button");
    InterFormContainer cnt = new InterFormContainer(sharedButton);
    InterFormContainer cnt2 = new InterFormContainer(sharedButton);
    Toolbar.setGlobalToolbar(true);
    Form hi = new Form("Transitions", new BorderLayout());
    Container c = new Container(BoxLayout.y());
    hi.add(BorderLayout.CENTER, c);
    hi.add(BorderLayout.SOUTH, cnt);
    Style bg = hi.getContentPane().getUnselectedStyle();
    bg.setBgTransparency(255);
    bg.setBgColor(0xff0000);
    Button showTransition = new Button("Show");
    Picker pick = new Picker();
    pick.setStrings("Slide", "SlideFade", "Cover", "Uncover", "Fade", "Flip");
    pick.setSelectedString("Slide");
    TextField duration = new TextField("10000", "Duration", 6, TextArea.NUMERIC);
    CheckBox horizontal = CheckBox.createToggle("Horizontal");
    pick.addActionListener((e) -> {
        String s = pick.getSelectedString().toLowerCase();
        horizontal.setEnabled(s.equals("slide") || s.indexOf("cover") > -1);
    });
    horizontal.setSelected(true);
    c.add(showTransition).add(pick).add(duration).add(horizontal);
    Form dest = new Form("Destination", new BorderLayout());
    sharedButton.addActionListener(e -> {
        if (sharedButton.getComponentForm() == hi) {
            dest.show();
        } else {
            hi.showBack();
        }
    });
    dest.add(BorderLayout.SOUTH, cnt2);
    bg = dest.getContentPane().getUnselectedStyle();
    bg.setBgTransparency(255);
    bg.setBgColor(0xff);
    dest.setBackCommand(dest.getToolbar().addCommandToLeftBar("Back", null, (e) -> hi.showBack()));
    showTransition.addActionListener((e) -> {
        int h = CommonTransitions.SLIDE_HORIZONTAL;
        if (!horizontal.isSelected()) {
            h = CommonTransitions.SLIDE_VERTICAL;
        }
        switch(pick.getSelectedString()) {
            case "Slide":
                hi.setTransitionOutAnimator(CommonTransitions.createSlide(h, true, duration.getAsInt(3000)));
                dest.setTransitionOutAnimator(CommonTransitions.createSlide(h, true, duration.getAsInt(3000)));
                break;
            case "SlideFade":
                hi.setTransitionOutAnimator(CommonTransitions.createSlideFadeTitle(true, duration.getAsInt(3000)));
                dest.setTransitionOutAnimator(CommonTransitions.createSlideFadeTitle(true, duration.getAsInt(3000)));
                break;
            case "Cover":
                hi.setTransitionOutAnimator(CommonTransitions.createCover(h, true, duration.getAsInt(3000)));
                dest.setTransitionOutAnimator(CommonTransitions.createCover(h, true, duration.getAsInt(3000)));
                break;
            case "Uncover":
                hi.setTransitionOutAnimator(CommonTransitions.createUncover(h, true, duration.getAsInt(3000)));
                dest.setTransitionOutAnimator(CommonTransitions.createUncover(h, true, duration.getAsInt(3000)));
                break;
            case "Fade":
                hi.setTransitionOutAnimator(CommonTransitions.createFade(duration.getAsInt(3000)));
                dest.setTransitionOutAnimator(CommonTransitions.createFade(duration.getAsInt(3000)));
                break;
            case "Flip":
                hi.setTransitionOutAnimator(new FlipTransition(-1, duration.getAsInt(3000)));
                dest.setTransitionOutAnimator(new FlipTransition(-1, duration.getAsInt(3000)));
                break;
        }
        dest.show();
    });
    hi.show();
}
Also used : Toolbar(com.codename1.ui.Toolbar) BoxLayout(com.codename1.ui.layouts.BoxLayout) Resources(com.codename1.ui.util.Resources) IOException(java.io.IOException) Form(com.codename1.ui.Form) Log(com.codename1.io.Log) Picker(com.codename1.ui.spinner.Picker) Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) Style(com.codename1.ui.plaf.Style) NetworkEvent(com.codename1.io.NetworkEvent) UIManager(com.codename1.ui.plaf.UIManager) CommonTransitions(com.codename1.ui.animations.CommonTransitions) SpanLabel(com.codename1.components.SpanLabel) TextField(com.codename1.ui.TextField) Dialog(com.codename1.ui.Dialog) Display(com.codename1.ui.Display) Label(com.codename1.ui.Label) Button(com.codename1.ui.Button) CN(com.codename1.ui.CN) TextArea(com.codename1.ui.TextArea) CheckBox(com.codename1.ui.CheckBox) InterFormContainer(com.codename1.ui.InterFormContainer) FlipTransition(com.codename1.ui.animations.FlipTransition) Form(com.codename1.ui.Form) FlipTransition(com.codename1.ui.animations.FlipTransition) InterFormContainer(com.codename1.ui.InterFormContainer) Container(com.codename1.ui.Container) InterFormContainer(com.codename1.ui.InterFormContainer) BorderLayout(com.codename1.ui.layouts.BorderLayout) Button(com.codename1.ui.Button) CheckBox(com.codename1.ui.CheckBox) Picker(com.codename1.ui.spinner.Picker) Style(com.codename1.ui.plaf.Style) TextField(com.codename1.ui.TextField)

Example 30 with CheckBox

use of com.vaadin.v7.ui.CheckBox in project CodenameOne by codenameone.

the class JavascriptCapturePhotoSample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    CheckBox useUserMedia = new CheckBox("Use UserMedia APIs for Photo Capture");
    useUserMedia.addActionListener(e -> {
        Display.getInstance().setProperty("javascript.useGetUserMedia", useUserMedia.isSelected() ? "true" : "false");
    });
    TextField width = new TextField();
    width.setHint("width");
    TextField height = new TextField();
    height.setHint("height");
    Button capture = new Button("Capture");
    Label imagePlaceholder = new Label();
    capture.addActionListener(e -> {
        int w = -1;
        int h = -1;
        try {
            w = Integer.parseInt(width.getText());
        } catch (Throwable t) {
        }
        try {
            h = Integer.parseInt(height.getText());
        } catch (Throwable t) {
        }
        String path = Capture.capturePhoto(w, h);
        if (path != null) {
            try {
                Image img = Image.createImage(path);
                imagePlaceholder.setIcon(img);
                hi.revalidate();
            } catch (Exception ex) {
                Log.e(ex);
            }
        }
    });
    hi.add(new Label("Photo Capture Demo"));
    hi.add(useUserMedia);
    hi.add(GridLayout.encloseIn(2, width, height));
    hi.add(capture);
    hi.add(imagePlaceholder);
    hi.show();
}
Also used : Form(com.codename1.ui.Form) Button(com.codename1.ui.Button) CheckBox(com.codename1.ui.CheckBox) Label(com.codename1.ui.Label) TextField(com.codename1.ui.TextField) Image(com.codename1.ui.Image) IOException(java.io.IOException)

Aggregations

CheckBox (com.vaadin.v7.ui.CheckBox)40 CheckBox (com.codename1.ui.CheckBox)18 Label (com.vaadin.ui.Label)15 ComboBox (com.vaadin.v7.ui.ComboBox)14 Button (com.codename1.ui.Button)12 TextField (com.vaadin.v7.ui.TextField)12 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)12 Form (com.codename1.ui.Form)11 Disease (de.symeda.sormas.api.Disease)11 Captions (de.symeda.sormas.api.i18n.Captions)11 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)11 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)11 List (java.util.List)11 Container (com.codename1.ui.Container)10 FacadeProvider (de.symeda.sormas.api.FacadeProvider)10 Strings (de.symeda.sormas.api.i18n.Strings)10 Label (com.codename1.ui.Label)9 TextField (com.codename1.ui.TextField)9 HorizontalLayout (com.vaadin.ui.HorizontalLayout)9 AbstractEditForm (de.symeda.sormas.ui.utils.AbstractEditForm)9