I basically want to divide a 300 by 300 JFrame window into like 30 squares (without drawing them all separately) and be able to access each of the squares (maybe put them into an array/arraylist/stack/vector/etc). Is this possible without writing drawRect(x, y, width, height) 30 times? Thanks in advance.
Share
You can keep your components in an ArrayList and get use of GridLayout
and the following snippet:
where x and y denotes the number of rows and columns respectively.
After that you can add components to the content of your JFrame object.
Sample code: