Search in sources :

Example 6 with AutoCompleteTextField

use of com.codename1.ui.AutoCompleteTextField in project CodenameOne by codenameone.

the class RTLLayoutAndPadding method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    Label l = new Label("Hi World");
    FlowLayout fl = new FlowLayout();
    fl.setAlign(CENTER);
    Container row = new Container(fl);
    row.add(new Label("Center"));
    $(row).selectAllStyles().setPaddingMillimeters(3f).setBgColor(0x003366).setBorder(RoundBorder.create());
    hi.add(row);
    fl = new FlowLayout();
    fl.setAlign(RIGHT);
    row = new Container(fl);
    row.add(new Label("Right"));
    $(row).selectAllStyles().setPaddingMillimeters(3f).setBgColor(0x003366).setBorder(RoundBorder.create());
    hi.add(row);
    fl = new FlowLayout();
    fl.setAlign(LEFT);
    row = new Container(fl);
    row.add(new Label("Left"));
    $(row).selectAllStyles().setPaddingMillimeters(3f).setBgColor(0x003366).setBorder(RoundBorder.create());
    hi.add(row);
    fl = new FlowLayout();
    fl.setAlign(CENTER);
    row = new Container(fl);
    row.add(new Label("Center"));
    $(row).selectAllStyles().setPaddingMillimeters(1f, 2f, 1f, 5f).setBgColor(0x003366).setBorder(RoundBorder.create());
    hi.add(row);
    AutoCompleteTextField tf = new AutoCompleteTextField("Red", "Green", "Blue");
    hi.add(FlowLayout.encloseIn(tf));
    hi.show();
}
Also used : Container(com.codename1.ui.Container) AutoCompleteTextField(com.codename1.ui.AutoCompleteTextField) FlowLayout(com.codename1.ui.layouts.FlowLayout) Form(com.codename1.ui.Form) Label(com.codename1.ui.Label)

Example 7 with AutoCompleteTextField

use of com.codename1.ui.AutoCompleteTextField in project CodenameOne by codenameone.

the class ThemeEditor method initMIDlet.

private void initMIDlet() {
    JavaSEPortWithSVGSupport.setShowEDTWarnings(false);
    JavaSEPortWithSVGSupport.setShowEDTViolationStacks(false);
    // its a UI form
    if (uiPreviewContent.getSelectedIndex() == uiPreviewContent.getModel().getSize() - 1) {
        previewPanel.removeAll();
        if (com.codename1.ui.Display.isInitialized()) {
            com.codename1.ui.Display.deinitialize();
        }
        JavaSEPortWithSVGSupport.setDefaultInitTarget(previewPanel);
        com.codename1.ui.Display.init(previewPanel);
        previewPanel.getComponent(0).setBounds(0, 0, get(widthResoltution), get(heightResolution));
        previewPanel.getComponent(0).setPreferredSize(new java.awt.Dimension(get(widthResoltution), get(heightResolution)));
        PickMIDlet.startMIDlet(themeHash);
    } else {
        Preferences.userNodeForPackage(getClass()).put("uiPreviewContent", (String) uiPreviewContent.getSelectedItem());
        Accessor.setTheme(themeHash);
        if (com.codename1.ui.Display.isInitialized()) {
            com.codename1.ui.Display.deinitialize();
        }
        previewPanel.removeAll();
        com.codename1.ui.Display.init(previewPanel);
        previewPanel.getComponent(0).setBounds(0, 0, get(widthResoltution), get(heightResolution));
        previewPanel.getComponent(0).setPreferredSize(new java.awt.Dimension(get(widthResoltution), get(heightResolution)));
        com.codename1.ui.util.UIBuilder.registerCustomComponent("Table", com.codename1.ui.table.Table.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("MediaPlayer", com.codename1.components.MediaPlayer.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("ContainerList", com.codename1.ui.list.ContainerList.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("ComponentGroup", com.codename1.ui.ComponentGroup.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("Tree", com.codename1.ui.tree.Tree.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("HTMLComponent", com.codename1.ui.html.HTMLComponent.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("RSSReader", com.codename1.components.RSSReader.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("FileTree", com.codename1.components.FileTree.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("WebBrowser", com.codename1.components.WebBrowser.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("NumericSpinner", com.codename1.ui.spinner.NumericSpinner.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("DateSpinner", com.codename1.ui.spinner.DateSpinner.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("TimeSpinner", com.codename1.ui.spinner.TimeSpinner.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("DateTimeSpinner", com.codename1.ui.spinner.DateTimeSpinner.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("GenericSpinner", com.codename1.ui.spinner.GenericSpinner.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("LikeButton", com.codename1.facebook.ui.LikeButton.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("InfiniteProgress", com.codename1.components.InfiniteProgress.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("MultiButton", com.codename1.components.MultiButton.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("SpanButton", com.codename1.components.SpanButton.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("SpanLabel", com.codename1.components.SpanLabel.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("Ads", com.codename1.components.Ads.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("MapComponent", com.codename1.maps.MapComponent.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("MultiList", com.codename1.ui.list.MultiList.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("ShareButton", com.codename1.components.ShareButton.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("OnOffSwitch", com.codename1.components.OnOffSwitch.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("ImageViewer", com.codename1.components.ImageViewer.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("AutoCompleteTextField", com.codename1.ui.AutoCompleteTextField.class);
        com.codename1.ui.util.UIBuilder.registerCustomComponent("Picker", com.codename1.ui.spinner.Picker.class);
        Display.getInstance().callSerially(new Runnable() {

            @Override
            public void run() {
                com.codename1.ui.util.UIBuilder builder = new com.codename1.ui.util.UIBuilder();
                final com.codename1.ui.Container c = builder.createContainer(resources, (String) uiPreviewContent.getSelectedItem());
                if (c instanceof com.codename1.ui.Form) {
                    if (c instanceof com.codename1.ui.Dialog) {
                        com.codename1.ui.animations.Transition t = ((com.codename1.ui.Dialog) c).getTransitionInAnimator();
                        ((com.codename1.ui.Dialog) c).setTransitionInAnimator(com.codename1.ui.animations.CommonTransitions.createEmpty());
                        ((com.codename1.ui.Dialog) c).showModeless();
                        ((com.codename1.ui.Dialog) c).setTransitionInAnimator(t);
                    } else {
                        com.codename1.ui.animations.Transition t = ((com.codename1.ui.Form) c).getTransitionInAnimator();
                        ((com.codename1.ui.Form) c).setTransitionInAnimator(com.codename1.ui.animations.CommonTransitions.createEmpty());
                        ((com.codename1.ui.Form) c).show();
                        ((com.codename1.ui.Form) c).setTransitionInAnimator(t);
                    }
                } else {
                    com.codename1.ui.Form f = new Form();
                    f.setTransitionInAnimator(com.codename1.ui.animations.CommonTransitions.createEmpty());
                    f.setLayout(new com.codename1.ui.layouts.BorderLayout());
                    f.addComponent(com.codename1.ui.layouts.BorderLayout.CENTER, c);
                    f.show();
                }
            }
        });
    }
}
Also used : Form(com.codename1.ui.Form) Form(com.codename1.ui.Form) UIBuilderOverride(com.codename1.ui.util.UIBuilderOverride) Hashtable(java.util.Hashtable)

Example 8 with AutoCompleteTextField

use of com.codename1.ui.AutoCompleteTextField in project CodenameOne by codenameone.

the class AutocompleteOverrideFilterSample method showForm.

public void showForm() {
    Form hi = new Form("Auto Complete", new BoxLayout(BoxLayout.Y_AXIS));
    final DefaultListModel<String> options = new DefaultListModel<>();
    AutoCompleteTextField ac = new AutoCompleteTextField(options) {

        @Override
        protected boolean filter(String text) {
            if (text.length() == 0) {
                return false;
            }
            String[] l = searchLocations(text);
            if (l == null || l.length == 0) {
                return false;
            }
            options.removeAll();
            for (String s : l) {
                options.addItem(s);
            }
            return true;
        }
    };
    ac.setMinimumElementsShownInPopup(5);
    hi.add(ac);
    hi.add(new SpanLabel("This demo requires a valid google API key to be set below " + "you can get this key for the webservice (not the native key) by following the instructions here: " + "https://developers.google.com/places/web-service/get-api-key"));
    hi.add(apiKey);
    hi.getToolbar().addCommandToRightBar("Get Key", null, e -> Display.getInstance().execute("https://developers.google.com/places/web-service/get-api-key"));
    hi.show();
}
Also used : AutoCompleteTextField(com.codename1.ui.AutoCompleteTextField) Form(com.codename1.ui.Form) BoxLayout(com.codename1.ui.layouts.BoxLayout) DefaultListModel(com.codename1.ui.list.DefaultListModel) SpanLabel(com.codename1.components.SpanLabel)

Aggregations

Form (com.codename1.ui.Form)7 AutoCompleteTextField (com.codename1.ui.AutoCompleteTextField)6 Container (com.codename1.ui.Container)3 Button (com.codename1.ui.Button)2 Label (com.codename1.ui.Label)2 BorderLayout (com.codename1.ui.layouts.BorderLayout)2 DefaultListModel (com.codename1.ui.list.DefaultListModel)2 SpanLabel (com.codename1.components.SpanLabel)1 Tabs (com.codename1.ui.Tabs)1 BoxLayout (com.codename1.ui.layouts.BoxLayout)1 FlowLayout (com.codename1.ui.layouts.FlowLayout)1 Resources (com.codename1.ui.util.Resources)1 UIBuilderOverride (com.codename1.ui.util.UIBuilderOverride)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 Hashtable (java.util.Hashtable)1 Timer (java.util.Timer)1 BackingStoreException (java.util.prefs.BackingStoreException)1 Preferences (java.util.prefs.Preferences)1