Search in sources :

Example 6 with DefaultListCellRenderer

use of com.codename1.ui.list.DefaultListCellRenderer in project CodenameOne by codenameone.

the class Spinner method initSpinnerRenderer.

void initSpinnerRenderer() {
    DefaultListCellRenderer render = ((DefaultListCellRenderer) super.getRenderer());
    render.setRTL(false);
    setRTL(false);
    render.setShowNumbers(false);
    render.setUIID("SpinnerRenderer");
    Component bgFocus = render.getListFocusComponent(this);
    bgFocus.setUIID("SpinnerRendererFocus");
    bgFocus.getSelectedStyle().setBgTransparency(0);
    bgFocus.getUnselectedStyle().setBgTransparency(0);
    render.setAlwaysRenderSelection(true);
}
Also used : DefaultListCellRenderer(com.codename1.ui.list.DefaultListCellRenderer) Component(com.codename1.ui.Component)

Example 7 with DefaultListCellRenderer

use of com.codename1.ui.list.DefaultListCellRenderer in project CodenameOne by codenameone.

the class AutoCompleteTextField method addPopup.

private void addPopup() {
    final Form f = getComponentForm();
    popup.removeAll();
    popup.setVisible(false);
    popup.setEnabled(false);
    filter(getText());
    final com.codename1.ui.List l = new com.codename1.ui.List(getSuggestionModel());
    if (getMinimumElementsShownInPopup() > 0) {
        l.setMinElementHeight(getMinimumElementsShownInPopup());
    }
    l.setScrollToSelected(false);
    l.setItemGap(0);
    for (ActionListener al : listeners) {
        l.addActionListener(al);
    }
    if (completionRenderer == null) {
        ((DefaultListCellRenderer<String>) l.getRenderer()).setShowNumbers(false);
    } else {
        l.setRenderer(completionRenderer);
    }
    l.setUIID("AutoCompleteList");
    l.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            pickedText = (String) l.getSelectedItem();
            setParentText(pickedText);
            fireActionEvent();
            // relaunch text editing if we are still editing
            if (Display.getInstance().isTextEditing(AutoCompleteTextField.this)) {
                Display.getInstance().editString(AutoCompleteTextField.this, getMaxSize(), getConstraint(), (String) l.getSelectedItem());
            }
            popup.setVisible(false);
            popup.setEnabled(false);
            f.repaint();
        }
    });
    byte[] units = popup.getStyle().getMarginUnit();
    if (units != null) {
        units[Component.LEFT] = Style.UNIT_TYPE_PIXELS;
        units[Component.TOP] = Style.UNIT_TYPE_PIXELS;
        popup.getAllStyles().setMarginUnit(units);
    }
    popup.getAllStyles().setMargin(LEFT, Math.max(0, getAbsoluteX()));
    int popupHeight = calcPopuupHeight(l);
    popup.setPreferredW(getWidth());
    popup.setHeight(popupHeight);
    popup.setWidth(getWidth());
    popup.addComponent(l);
    popup.layoutContainer();
    // block the reflow of this popup, which can cause painting problems
    dontCalcSize = true;
    if (f != null) {
        if (popup.getParent() == null) {
            Container lay = f.getLayeredPane(AutoCompleteTextField.this.getClass(), true);
            lay.setLayout(new LayeredLayout());
            Container wrapper = new Container();
            wrapper.add(popup);
            lay.addComponent(wrapper);
        }
        f.revalidate();
    }
}
Also used : ActionEvent(com.codename1.ui.events.ActionEvent) ActionListener(com.codename1.ui.events.ActionListener) ArrayList(java.util.ArrayList) LayeredLayout(com.codename1.ui.layouts.LayeredLayout)

Aggregations

DefaultListCellRenderer (com.codename1.ui.list.DefaultListCellRenderer)4 ArrayList (java.util.ArrayList)3 EncodedImage (com.codename1.ui.EncodedImage)2 AnimationObject (com.codename1.ui.animations.AnimationObject)2 UIBuilderOverride (com.codename1.ui.util.UIBuilderOverride)2 Component (java.awt.Component)2 DefaultListCellRenderer (javax.swing.DefaultListCellRenderer)2 JList (javax.swing.JList)2 SVG (com.codename1.impl.javase.SVG)1 Component (com.codename1.ui.Component)1 Timeline (com.codename1.ui.animations.Timeline)1 ActionEvent (com.codename1.ui.events.ActionEvent)1 ActionListener (com.codename1.ui.events.ActionListener)1 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)1 BorderLayout (java.awt.BorderLayout)1 BufferedImage (java.awt.image.BufferedImage)1 Comparator (java.util.Comparator)1 Vector (java.util.Vector)1 ComboBoxModel (javax.swing.ComboBoxModel)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1