Modify the program so that each Circle object has a label that it stores and displays (when drawn via its draw()) method. (You can change the circles to be not filled-in and draw the text in white as in the next figure.) Here's the fun part: modify the SplatPanel program so that instead of storing and creating and drawing five arbitrary Circles, it generates n random Circles and stores them on an ArrayList. Modify the paintComponent() method so that instead
| 2 pages
| 386 words
| 194 views
Trusted by 2+ million users, 1000+ happy students everyday
Assignment #10Two projects:Programming Project 6.22 and the following modification to the Splat program.Splat, RevisedStart with the "Splat" program from Ch. 4, Listings 4.7, 4.8, and 4.9. Create a Java project with these three files, and run it to be sure it works.Modify the program so that eachCircleobject has a label that it stores and displays (when drawn via itsdraw()) method. You can assume that the label is a very shortStringthat will fit in theCircle. Test that your program works by modifyingSplatPanelto give the circles names. (You can change the circles to be not filled-in and draw the text in white as in the next figure.)Here's the fun part: modify theSplatPanelprogram so that instead of storing and creating and drawing five arbitraryCircles, it generatesnrandomCirclesand stores them on anArrayList. Prompt the user via a dialog box for the number of circles. This entails a lot ofthings:Use of the dialog box to prompt for and retrieve the number of circles.Replacing the fiveCircleinstance variables with a singleArrayListinstance variable.Writing a loop that generates the appropriate number of randomCircles.Be sure to generate circles that fit on-screen!Use appropriate logic on the random number generation to be sure.Use the index of the loop to "name" eachCircle.Generate random colors like this:Color color = new Color(generator.nextInt(0xffffff));(wheregeneratoris yourRandomobject).Modify thepaintComponent()method so that instead of trying to print the five arbitraryCircles (which you've trashed), it iterates through the list ofCircles and prints each one.
Found this document preview useful?
You are reading a preview Upload your documents to download or Become a Desklib member to get accesss