i have two classes - one just creates the jFrame and the other is for displaying shapes onto this Frame
right now the code just displays a random rectangle every time i run the program
but i want to add a timer so a rectangle appears every second
also the other rectangles should not disappear (so eventually the frame fills with rectangles)
here is the shapes class:
so how do i add a timer function to this code to make a random rectangle appear every second?
Once you decide an which approach to use, you will need to create an addShape(...) method. That you can first test out manually. Once this works you then start working with the Swing Timer to generate random Shapes dynamically.
i had a homework assignment in college that was similar to this. the instructor had us make a shape class and use a Vector to hold them. during repaint we went through the vector andd repainted them all. later i made it into a "real" program and i used an ArrayList that held BufferedImages