Search in sources :

Example 6 with ComboBox

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

the class DefaultLookAndFeel method refreshTheme.

/**
 * {@inheritDoc}
 */
public void refreshTheme(boolean b) {
    chkBoxImages = null;
    comboImage = null;
    rButtonImages = null;
    chkBoxImagesFocus = null;
    rButtonImagesFocus = null;
    super.refreshTheme(b);
    UIManager m = getUIManager();
    Image combo = m.getThemeImageConstant("comboImage");
    if (combo != null) {
        setComboBoxImage(combo);
    } else {
        if (Font.isNativeFontSchemeSupported()) {
            Style c = UIManager.getInstance().createStyle("ComboBox.", "", false);
            combo = FontImage.createMaterial(FontImage.MATERIAL_ARROW_DROP_DOWN, c);
            setComboBoxImage(combo);
        }
    }
    updateCheckBoxConstants(m, false, "");
    updateCheckBoxConstants(m, true, "Focus");
    updateRadioButtonConstants(m, false, "");
    updateRadioButtonConstants(m, true, "Focus");
}
Also used : Image(com.codename1.ui.Image) FontImage(com.codename1.ui.FontImage)

Example 7 with ComboBox

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

the class HTMLForm method reset.

/**
 * Called when a form reset is needed and resets all the form fields to their default values.
 */
void reset() {
    for (Enumeration e = defaultValues.keys(); e.hasMoreElements(); ) {
        Object input = e.nextElement();
        if (input instanceof TextArea) {
            // catches both textareas and text input fields
            String defVal = (String) defaultValues.get(input);
            if (defVal == null) {
                defVal = "";
            }
            ((TextArea) input).setText(defVal);
        } else if (input instanceof ComboBox) {
            OptionItem defVal = (OptionItem) defaultValues.get(input);
            ComboBox combo = ((ComboBox) input);
            if (defVal != null) {
                combo.setSelectedItem(defVal);
            } else if (combo.size() > 0) {
                combo.setSelectedIndex(0);
            }
        }
    }
    for (Enumeration e = defaultCheckedButtons.elements(); e.hasMoreElements(); ) {
        Button b = (Button) e.nextElement();
        if (!b.isSelected()) {
            setButton(b, true);
        }
    }
    for (Enumeration e = defaultUncheckedButtons.elements(); e.hasMoreElements(); ) {
        Button b = (Button) e.nextElement();
        if (b.isSelected()) {
            setButton(b, false);
        }
    }
}
Also used : Enumeration(java.util.Enumeration) TextArea(com.codename1.ui.TextArea) RadioButton(com.codename1.ui.RadioButton) Button(com.codename1.ui.Button) ComboBox(com.codename1.ui.ComboBox)

Example 8 with ComboBox

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

the class Calendar method setYearRange.

/**
 * Sets the Calendar min and max years
 *
 * @param minYear the min year
 * @param maxYear the max year
 */
public void setYearRange(int minYear, int maxYear) {
    if (minYear > maxYear) {
        throw new IllegalArgumentException("Max year should be bigger than or equal to min year!");
    }
    // The year combobox may not exist in the current context
    if (year != null) {
        Object previouslySelectedYear = year.getSelectedItem();
        Vector years = new Vector();
        for (int i = maxYear; i >= minYear; i--) {
            years.addElement("" + i);
        }
        ListModel yearModel = new DefaultListModel(years);
        year.setModel(yearModel);
        if (years.contains(previouslySelectedYear)) {
            year.setSelectedItem(previouslySelectedYear);
        }
    }
}
Also used : ListModel(com.codename1.ui.list.ListModel) DefaultListModel(com.codename1.ui.list.DefaultListModel) DefaultListModel(com.codename1.ui.list.DefaultListModel) Vector(java.util.Vector)

Aggregations

Button (com.codename1.ui.Button)5 RadioButton (com.codename1.ui.RadioButton)5 TextArea (com.codename1.ui.TextArea)5 Component (com.codename1.ui.Component)3 Enumeration (java.util.Enumeration)3 Hashtable (java.util.Hashtable)3 Vector (java.util.Vector)3 ComboBox (com.codename1.ui.ComboBox)2 Container (com.codename1.ui.Container)2 List (com.codename1.ui.List)2 TextField (com.codename1.ui.TextField)2 SelectionListener (com.codename1.ui.events.SelectionListener)2 ListModel (com.codename1.ui.list.ListModel)2 FontImage (com.codename1.ui.FontImage)1 Image (com.codename1.ui.Image)1 Label (com.codename1.ui.Label)1 DataChangedListener (com.codename1.ui.events.DataChangedListener)1 Dimension (com.codename1.ui.geom.Dimension)1 BorderLayout (com.codename1.ui.layouts.BorderLayout)1 BoxLayout (com.codename1.ui.layouts.BoxLayout)1