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);
}
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();
}
}
Aggregations