AutoCompleteTextField NullPointerException

20 views
Skip to first unread message

shop.servic...@gmail.com

unread,
Apr 10, 2019, 7:00:18 PM4/10/19
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA NetBeans 8.2
Desktop OS Windws 10 Pro
Simulator Latest
Device PC, IOS 12+ Android 6+

[EDT] 0:2:35,975 - Exception: java.lang.NullPointerException - null
java.lang.NullPointerException
 at com.codename1.ui.AutoCompleteTextField$FormPointerPressListener.actionPerformed(AutoCompleteTextField.java:464)
 at com.codename1.ui.util.EventDispatcher.fireActionSync(EventDispatcher.java:459)
 at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:362)
 at com.codename1.ui.Form.pointerPressed(Form.java:2946)
 at com.codename1.ui.Component.pointerPressed(Component.java:4502)
 at com.codename1.ui.Display.handleEvent(Display.java:2145)
 at com.codename1.ui.Display.edtLoopImpl(Display.java:1152)
 at com.codename1.ui.Display.mainEDTLoop(Display.java:1070)
 at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
 at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)

Uncaught Exception is this code:
Container layered = f.getLayeredPane(AutoCompleteTextField.getClass(), true);
Form f = getComponentForm();
Where "f" = null;Causing the Exception.

Thoughts?

Regards



Shai Almog

unread,
Apr 10, 2019, 10:17:39 PM4/10/19
to CodenameOne Discussions
Did you remove the auto-complete component (or one of its parents) from the form dynamically?

shop.servic...@gmail.com

unread,
Apr 11, 2019, 11:20:19 AM4/11/19
to CodenameOne Discussions
I am using AutoCompleteTextField as a rendered Table Cell. 
After looking more closely, I was instantiating a new AutoCompleteTextField  within the createCell method.
I have stored a new createCell( instance in a vector and pass that element to the createCell method.
for each row, I instantiate and store in this Vector
                Vector myAutoCompleteTextFields.addElement(new AutoCompleteTextField(CarFaxLaborTasks));

                        cell = (AutoCompleteTextField) myAutoCompleteTextFields.elementAt(row);
                        ((AutoCompleteTextField) cell).setText((String) super.getModel().getValueAt(row, column));


This resolved the null pointer exception.
However I am experiencing a display issue.
Initially the Table renders the strings as expected, however when I touch to edit then touch elsewhere (lose focus) the
cell is no longer rendered in that the cell is blank. (When querying the table contents, the data is as expected. Just not seeing in screen)

Thoughts?

Thanks in advance

Regards

Shai Almog

unread,
Apr 11, 2019, 10:26:31 PM4/11/19
to CodenameOne Discussions
I suggest using a single Label or TextArea instance within the renderer. When you reuse the instance the renderer manipulates the component and that triggers artifacts. To make the component look like AutoComplete just use setUIID().

shop.servic...@gmail.com

unread,
Apr 12, 2019, 11:30:58 AM4/12/19
to CodenameOne Discussions
When I change the Component from AutoCompleteTextFiemd to TextArea in
protected Component createCell(Object value, final int row, final int column, boolean editable) method,
The text is rendered appropriately with the exception that I am not able to interact with the AutoCompleteTextFiemd as a pupup of suggestions when this column takes focus.

Thoughts?

Regards

Shai Almog

unread,
Apr 13, 2019, 1:26:28 AM4/13/19
to CodenameOne Discussions
You shouldn't be able to interact with a renderer. Do you mean you don't see the focus behind?
It's probably because the component is opaque.
Reply all
Reply to author
Forward
0 new messages