MUPanel class — in file MUPanel.javaStart with the MUPanel.java file from either your Lab 1 project or another NetBeans project that you have written. There are three important locations in the class definition where you need to pay attention:
1. DECLARE all of the Initials
andLogo
objects you need (minimum of 2 objects from each of those classes) at the top of theMUPanel
class definition, before the heading of theMUPanel
constructor method2. Inside the MUPanel
constructor method, INSTANTIATE the objects you previously declared (that means use thenew
operator!)3. Inside the paintComponent
method, USE the objects you previously declared and instantiated (for this assignment, you will be calling thedraw
method of each object)
In the following sample class definition skeleton, these three areas are color-coded for your reference:
public class MUPanel extends JPanel {
// PRIVATE OBJECTS ARE DECLARED IN THIS AREA
public MUPanel() {
setLayout(null);
setPreferredSize(new Dimension(800, 600));
setName("CSC 120 PA1 - My Initials and Logo!");
setBackground(Color.WHITE);
// INSTANTIATE THE OBJECTS DECLARED ABOVE IN THIS AREA!
} // end of constructor
public void paintComponent( Graphics g ) {
super.paintComponent(g);
// USE THE OBJECTS IN THIS AREA (DRAW THEM)!
} // end of paintComponent()
/***********************************************
* Do NOT change or delete anything below here!
***********************************************/
} // end of class MUPanel
Logo class — in file Logo.javaStart with the Logo.java file linked to the PA1 assignment page. Copy the file into your new project. There are three important locations in the class definition where you need to pay attention:
1. DECLARE all of the private data you need (must at least have an Integer
named anchorX and anotherInteger
named anchorY) at the top of the class definition, before the heading of theLogo
constructor method.2. The constructor method must have the same name as the class (namely, Logo), and store the parameters in the private data variables of the class. See the constructor of the Balloon, Flag or other classes for details.
3. There must be a draw method that will cause the Logo object to be drawn in the output window. This is where most of the work for the assignment will be. The program must draw the shapes that make up the Logo relative to the (anchorX, anchorY) point of the object. Once again, see the draw method of the Balloon or Flag class for an example of how to do this.
In the following sample class definition skeleton, these three areas are color-coded for your reference:
public class Logo {
// DECLARE anchorX, anchorY, AND ANY OTHER DATA YOU NEED IN THIS AREA!
public Logo( Integer x, Integer y ) {
// STORE THE PARAMETERS IN THE PRIVATE DATA MEMBERS
// AS AN EXAMPLE, YOU SHOULD DO SOMETHING LIKE THIS FOR ALL PARAMETERS:
anchorX = x;
} // end of constructor
public void draw( Graphics g ) {
// USE g.setColor, g.drawRect, g.fillOval, ETC. TO DISPLAY YOUR LOGO
// IN THE OUTPUT WINDOW!
} // end of draw()
} // end of class Logo
Initials class — in file Initials.javaSame ideas as for the Logo class above....