deanbrowne / j4me

Automatically exported from code.google.com/p/j4me
1 stars 1 forks source link

ArrayOutBoundException While Scrolling and Incorrect Top of Screen value #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

I've a Dialog with several component. 
This screen has a page next / page previous menu.
Each time I change from a page to another, I delete all components within
dialog and re add some components.

I run into an ArrayOutOfBoundException when the store hightlighted
component is upper than the actual number of components.

I made the following updates in Dialog.java in order to reset the
highlightcomponent number.

    public void delete (Component component)
    {
                 delete(components.indexOf(component));

    }

    public void delete (int index)
    {
        clearLayout();
        if(highlightedComponent >= index)
            highlightedComponent = -1;
        components.removeElementAt( index );
    }

    public void deleteAll ()
    {
        clearLayout();
        highlightedComponent = -1;
        components.removeAllElements();
    }

once I fixed this, I run into another problem :  the top of screen is
truncated.

I fixed it by resetting the TopOfScreen value into the Dialog.clearLayout()
method : 
private synchronized void clearLayout ()
{
    componentWidths = null;
    absoluteHeights = null;
        // reset the top of Screen used for scrolling
    topOfScreen = 0;
}

Original issue reported on code.google.com by jmherme...@gmail.com on 7 Jan 2008 at 2:34

GoogleCodeExporter commented 9 years ago
Fixed in /trunk.

Original comment by deanbro...@gmail.com on 16 Jan 2008 at 9:26

GoogleCodeExporter commented 9 years ago
Verified on 1.0.2

Original comment by jmherme...@gmail.com on 21 Jan 2008 at 10:13