use of com.codename1.ui.AutoCompleteTextField in project CodenameOne by codenameone.
the class PreviewInSimulator method main.
/**
* Called back from simulateDeviceActionPerformed to show the simulator skin
*/
public static void main(String[] argv) {
com.codename1.ui.Display.init(new Runnable() {
public void run() {
try {
Preferences pref = Preferences.userNodeForPackage(PreviewInSimulator.class);
String theme = pref.get("previewTheme", null);
File resFile = new File(pref.get("previewResource", null));
String baseResDir = pref.get("baseResourceDir", null);
if (baseResDir != null) {
JavaSEPort.setBaseResourceDir(new File(baseResDir));
}
String selection = pref.get("previewSelection", null);
Resources res = Resources.open(new FileInputStream(resFile));
if (theme == null || theme.length() == 0) {
if (com.codename1.ui.Display.getInstance().hasNativeTheme()) {
com.codename1.ui.Display.getInstance().installNativeTheme();
}
} else {
com.codename1.ui.plaf.UIManager.getInstance().setThemeProps(res.getTheme(theme));
}
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);
com.codename1.ui.util.UIBuilder builder = new com.codename1.ui.util.UIBuilder();
com.codename1.ui.Container c = builder.createContainer(res, selection);
if (c instanceof com.codename1.ui.Form) {
((com.codename1.ui.Form) c).refreshTheme();
if (c instanceof com.codename1.ui.Dialog) {
((com.codename1.ui.Dialog) c).showModeless();
} else {
((com.codename1.ui.Form) c).show();
}
} else {
com.codename1.ui.Form f = new com.codename1.ui.Form();
f.setLayout(new com.codename1.ui.layouts.BorderLayout());
f.addComponent(com.codename1.ui.layouts.BorderLayout.CENTER, c);
f.refreshTheme();
f.show();
}
} catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(null, "Error While Running In Simulator: " + ex, "Error", JOptionPane.ERROR_MESSAGE);
}
}
});
}
use of com.codename1.ui.AutoCompleteTextField in project CodenameOne by codenameone.
the class AutocompleteAsyncTest method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", BoxLayout.y());
DefaultListModel options = new DefaultListModel();
class Query {
Timer handle;
String text;
private void cancel() {
if (handle != null) {
handle.cancel();
}
handle = null;
text = null;
}
}
Query query = new Query();
String[] db = new String[] { "les Escaldes", "Andorra la Vella", "Umm al Qaywayn", "Ras al-Khaimah", "Khawr Fakkān", "Dubai", "Dibba Al-Fujairah", "Dibba Al-Hisn", "Sharjah", "Ar Ruways", "Al Fujayrah", "Al Ain", "Ajman", "Adh Dhayd", "Abu Dhabi", "Zaranj", "Taloqan", "Shīnḏanḏ", "Shibirghān", "Shahrak", "Sar-e Pul", "Sang-e Chārak", "Aībak", "Rustāq", "Qarqīn", "Qarāwul", "Pul-e Khumrī", "Paghmān", "Nahrīn", "Maymana", "Mehtar Lām", "Mazār-e Sharīf", "Lashkar Gāh", "Kushk", "Kunduz", "Khōst", "Khulm", "Khāsh", "Khanabad", "Karukh", "Kandahār", "Kabul", "Jalālābād", "Jabal os Saraj", "Herāt", "Ghormach", "Ghazni", "Gereshk", "Gardēz", "Fayzabad", "Farah", "Kafir Qala", "Charikar", "Barakī Barak", "Bāmyān", "Balkh", "Baghlān", "Ārt Khwājah", "Āsmār", "Asadābād", "Andkhōy", "Bāzārak", "Markaz-e Woluswalī-ye Āchīn", "Saint John’s", "The Valley", "Sarandë", "Kukës", "Korçë", "Gjirokastër", "Elbasan", "Burrel", "Vlorë", "Tirana", "Shkodër", "Patos Fshat", "Lushnjë", "Lezhë", "Laç", "Kuçovë", "Krujë", "Kavajë", "Fier-Çifçi", "Fier", "Durrës", "Berat", "Kapan", "Goris", "Hats’avan", "Artashat", "Ararat", "Yerevan", "Ejmiatsin", "Spitak", "Sevan", "Masis", "Vanadzor", "Gavarr", "Hrazdan", "Armavir", "Gyumri", "Ashtarak", "Abovyan", "Saurimo", "Lucapa", "Luau", "Uíge", "Soio", "Nzeto", "N’dalatando", "Mbanza Congo", "Malanje", "Luanda", "Caxito", "Cabinda", "Sumbe", "Namibe", "Menongue", "Luena", "Lubango", "Longonjo", "Lobito", "Cuito", "Huambo", "Catumbela", "Catabola", "Camacupa", "Caluquembe", "Caála", "Benguela", "Zárate", "Villa Ocampo", "Villa Lugano", "Villaguay", "Villa Gesell", "Tigre", "Tandil", "San Vicente", "Santo Tomé", "Santa Elena", "San Pedro", "San Luis del Palmar", "San Lorenzo", "San Javier", "San Isidro", "Saladas" };
AutoCompleteTextField atf = new AutoCompleteTextField(options) {
@Override
protected boolean filter(String text) {
if (text.length() == 0) {
options.removeAll();
if (query.handle != null) {
query.handle.cancel();
}
return true;
}
if (Objects.equals(query.text, text)) {
return false;
}
if (query.handle != null) {
query.handle.cancel();
}
query.text = text;
query.handle = CN.setTimeout(1000, () -> {
query.handle = null;
query.text = null;
options.removeAll();
for (String city : db) {
if (city.toLowerCase().startsWith(text.toLowerCase())) {
options.addItem(city);
}
}
updateFilterList();
});
return false;
}
};
hi.add(atf);
hi.show();
}
use of com.codename1.ui.AutoCompleteTextField in project CodenameOne by codenameone.
the class AutocompleteInTabsTest method start.
public void start() {
if (current != null) {
current.show();
return;
}
Tabs tabs = new Tabs();
Container tabsContainer1 = new Container(new BorderLayout());
Container tabsContainer2 = new Container(new BorderLayout());
Form hi = new Form("Popup test");
AutoCompleteTextField autocompleteTab1 = new AutoCompleteTextField("1", "2", "3", "11", "22", "33");
// autocompleteTab1.setMinimumLength(1);
AutoCompleteTextField autocompleteTab2 = new AutoCompleteTextField("1", "2", "3", "4", "11", "22", "33", "44");
autocompleteTab2.setMinimumLength(1);
// pop up appears to be
// drawn semi off screen and
// see attached screenshot in email
tabsContainer1.add(BorderLayout.CENTER, autocompleteTab1);
tabs.addTab("working tab", tabsContainer1);
tabsContainer2.add(BorderLayout.CENTER, autocompleteTab2);
tabs.addTab("failing tab", tabsContainer2);
hi.add(tabs);
hi.show();
}
use of com.codename1.ui.AutoCompleteTextField in project CodenameOne by codenameone.
the class AutocompleteSample2788 method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Popup test", BorderLayout.absolute());
AutoCompleteTextField autocomplete = new AutoCompleteTextField("1", "2", "3", "11", "22", "33");
autocomplete.setMinimumLength(1);
Button tapMe = new Button("Tap me leaving the popup opened");
tapMe.addActionListener(l -> {
hi.replace(autocomplete, new Label("other content"), null);
hi.revalidate();
});
hi.add(BorderLayout.CENTER, autocomplete);
hi.add(BorderLayout.NORTH, tapMe);
hi.show();
}
use of com.codename1.ui.AutoCompleteTextField in project CodenameOne by codenameone.
the class AutocompleteTest3334 method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", BoxLayout.y());
AutoCompleteTextField act = new AutoCompleteTextField("Red", "Green", "Blue", "Orange", "Yellow");
act.setMinimumElementsShownInPopup(5);
Button down = new Button();
Container cnt = new Container(new BorderLayout());
FontImage.setMaterialIcon(down, FontImage.MATERIAL_KEYBOARD_ARROW_DOWN);
cnt.add(BorderLayout.CENTER, act);
cnt.add(BorderLayout.EAST, down);
down.addActionListener(evt -> {
act.showPopup();
});
hi.add(cnt);
hi.show();
}
Aggregations