Hi,

No, I'm going to show the code (really simple) for validation.

    private void formaTienda(final Form fmLiber) {
        final Form fmTienda = new Form(new BorderLayout());
        fmTienda.getToolbar().setBackCommand("", e -> fmLiber.showBack());
        fmTienda.getToolbar().getStyle().setAlignment(Label.LEFT);
        fmTienda.setTitle(idioma.getTiendas());

        TextField txNombreFiltro = new TextField();
        TextField txNombreBusqueda = new TextField();
        txNombreBusqueda.setHint(idioma.getTienda());

        Container cnTiendas = new Container(BoxLayout.y());
        cnTiendas.setScrollableY(true);

        Container cnBusqueda = new Container(new 
BorderLayout()).add(BorderLayout.CENTER, txNombreBusqueda);
        Container cnFiltro = new Container(new BorderLayout());

        Style s = UIManager.getInstance().getComponentStyle("Menu");
        FontImage iBusqueda = (FontImage) 
FontImage.createMaterial(FontImage.MATERIAL_SEARCH, s);
        Button btBusqueda = new Button(iBusqueda, "Transparent");
        cnBusqueda.add(BorderLayout.WEST, btBusqueda);
        btBusqueda.addActionListener((ActionListener) (ActionEvent e) -> {
            ArrayList lArt = leeArrayListTienda(txNombreBusqueda.getText(), 
"N");
            if (lArt != null) {
                if (lArt.size() < LIMITE_DATOS) {
                    cnTiendas.removeAll();
                    for (int i = 0; i < lArt.size(); i++) {
                        Tienda tDa = (Tienda) lArt.get(i);
                        Container cnItemTienda = creaItemTienda(fmTienda, 
tDa);
                        cnTiendas.add(cnItemTienda);
                    }
                    cnTiendas.revalidate();
                    fmTienda.replace(cnBusqueda, cnFiltro, 
CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, true, 200));
                } else {
                    Dialog.show(idioma.getInformacion(), 
idioma.getMensaje21(), idioma.getContinuar(), null);
                }
            } else {
                Dialog.show(idioma.getInformacion(), idioma.getMensaje41(), 
idioma.getContinuar(), null);
            }
        });

        FontImage iFiltro = (FontImage) 
FontImage.createMaterial(FontImage.MATERIAL_FILTER_LIST, s);
        Button btFiltro = new Button(iFiltro, "Transparent");
        btFiltro.setVerticalAlignment(Label.BOTTOM);
        btFiltro.setAlignment(CENTER);
        btFiltro.setTextPosition(Label.BOTTOM);
        cnFiltro.add(BorderLayout.WEST, btFiltro);
        cnFiltro.add(BorderLayout.CENTER, txNombreFiltro);

        btFiltro.addActionListener((ActionListener) (ActionEvent e) -> {
            txNombreBusqueda.setText("");
            txNombreFiltro.setText("");
            fmTienda.replace(cnFiltro, cnBusqueda, 
CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, true, 200));
            cnTiendas.removeAll();
        });

        txNombreFiltro.addDataChangeListener((int type, int index) -> {
            String t = txNombreFiltro.getText();
            if (t.length() < 1) {
                for (Component cmp : cnTiendas) {
                    cmp.setHidden(false);
                    cmp.setVisible(true);
                }
            } else {
                t = t.toLowerCase();
                for (Component cmp : cnTiendas) {
                    boolean show = false;
                    String val = null;
                    if (cmp instanceof Container) {
                        val = (String) cmp.getClientProperty("busqueda");
                    }
                    show = val != null && val.toLowerCase().indexOf(t) > -1;
                    cmp.setHidden(!show);
                    cmp.setVisible(show);
                }
            }
            cnTiendas.animateLayout(250);
        });

        s = UIManager.getInstance().getComponentStyle("Title");
        FontImage iInformacion = 
FontImage.createMaterial(FontImage.MATERIAL_INFO, s);
        fmTienda.getToolbar().addCommandToRightBar(new Command("", 
iInformacion) {
            @Override
            public void actionPerformed(ActionEvent evt) {
                muestraInformacion(fmTienda, idioma.getTiendas(), 
idioma.getMensaje68() + idioma.getMensaje23());
            }
        });

        FloatingActionButton btNuevo = 
FloatingActionButton.createFAB(FontImage.MATERIAL_ADD);
        btNuevo.bindFabToContainer(fmTienda.getContentPane(), 
Component.RIGHT, Component.BOTTOM);
        btNuevo.addActionListener((e) -> {
            Tienda tDa = new Tienda();
            mantenimientoTienda(fmTienda, tDa, ADICIONAR);
            cnTiendas.revalidate();
        });

        fmTienda.add(BorderLayout.NORTH, cnBusqueda);
        fmTienda.add(BorderLayout.CENTER, cnTiendas);
        fmTienda.setTransitionOutAnimator(CommonTransitions.createSlide(
                CommonTransitions.SLIDE_VERTICAL, true, 500));
        fmTienda.show();
    }

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/0e9955bc-073e-4875-8257-4c2116c0144e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to