We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Advice about my UI Code
Pages: 1 2 
Advice about my UI Code? (Read 2832 times)
Re: Advice about my UI Code?
Reply #15 - Jan 29th, 2010, 12:21am
 
danielt wrote on Jan 28th, 2010, 7:14pm:
What do you mean when you say should test bounds


Well if you try and get something from the ArrayList when it's empty or from an index that is empty you're going to get an error: so make sure the ArrayList size() is greater than the index being accessed before actually calling get Wink

Strictly speaking in the code you post you won't need it as you're calling get from a loop that iterates over the length of the ArrayList, but there may be times when you want to get an individual Panel by its id and that's when not checking bounds might bite you.

And yes you will need a Component class - I guess PhiLho's code assumes 'Component' as a GUI element.  In your case I suspect you want this to be either a parent class for all your components or an Interface (could be empty) that they all implement.
Pages: 1 2