admin管理员组文章数量:1287956
I had an error placing a label on a LayeredPane on my MovebyDrag screen, with a 2x1 table layout, placing a control container having a 6% height constraint in the first row, the field in the 2nd row. I have successfully placed the label on the LayeredPane on MovebyDrag (setup class) at Index 6, but when I Replay (viewing class) my activity movement I get the error: java.lang.IndexOutOfBoundsException: Index 6 out of bounds for length 0.
I am using the following block, which successfully reads the index location recorded in the db (142) and places the player on the Container field added to a Form named monitor on Replay with the same Container setup as MovebyDrag:
tlwloc = currentRow.getString(5); // location for LW label returned from pandr.db
tlwloci = Integer.parseInt(tlwloc);
((Container) field.getComponentAt(tlwloci)).add(lwlbl);
I am attempting to use the same logic for the ball location (Container with Index 6 recorded in the db, since my initial test on the LayeredPane is with a 3x4 grid on the LayeredPane) to place the ball on the LayeredPane gls (which will eventually have twice as many grid cells as field), created as a Container on the top level of the form, using:
tbloc = currentRow.getString(4);// location for ball label returned from pandr.db
tbloci = Integer.parseInt(tbloc);
((Container) gls.getComponentAt(tbloci)).add(blbl);
Is my error caused because the LayeredPane is not recognized as a Container, so the Index location fails? Has anyone had success finding a container on a LayeredPane by Index?
I had an error placing a label on a LayeredPane on my MovebyDrag screen, with a 2x1 table layout, placing a control container having a 6% height constraint in the first row, the field in the 2nd row. I have successfully placed the label on the LayeredPane on MovebyDrag (setup class) at Index 6, but when I Replay (viewing class) my activity movement I get the error: java.lang.IndexOutOfBoundsException: Index 6 out of bounds for length 0.
I am using the following block, which successfully reads the index location recorded in the db (142) and places the player on the Container field added to a Form named monitor on Replay with the same Container setup as MovebyDrag:
tlwloc = currentRow.getString(5); // location for LW label returned from pandr.db
tlwloci = Integer.parseInt(tlwloc);
((Container) field.getComponentAt(tlwloci)).add(lwlbl);
I am attempting to use the same logic for the ball location (Container with Index 6 recorded in the db, since my initial test on the LayeredPane is with a 3x4 grid on the LayeredPane) to place the ball on the LayeredPane gls (which will eventually have twice as many grid cells as field), created as a Container on the top level of the form, using:
tbloc = currentRow.getString(4);// location for ball label returned from pandr.db
tbloci = Integer.parseInt(tbloc);
((Container) gls.getComponentAt(tbloci)).add(blbl);
Is my error caused because the LayeredPane is not recognized as a Container, so the Index location fails? Has anyone had success finding a container on a LayeredPane by Index?
Share Improve this question asked Feb 23 at 4:01 curtjacobs1curtjacobs1 3511 silver badge8 bronze badges 1- Thanks for the observation, Deep Watch. I had the controls in place but didn't complete the setup transfer from MovebyDrag before I ran the app, and didn't pick up on the error like you did. – curtjacobs1 Commented Feb 23 at 5:02
1 Answer
Reset to default 1The error is not because the LayeredPane isn’t a Container, the LayeredPane really is one, the issue seems to be the error that the code is not finding the expected component. In the setup, a container is added and located at index 6, but in replay the LayeredPane’s list of components is empty or it is none matching with what was expected. The result of this contributes to an IndexOutOfBoundsException when trying to get a component that isn’t ther. Instead, it might be better to check if the container actually exists, or at least keep a direct reference to it rather than by its index.
本文标签:
版权声明:本文标题:codenameone - Why is Find By Index on a LayeredPane not locating the Container to accept a label? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741321173a2372213.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论