hey ,i am new to the site as java bluej , i have drawn a flag using bluej using many objects like circle and rectangle ...
i wanna combine the objects into one to move it together , what should i do ?
the code source:
/**
* This class represents a simple picture. You can draw the picture using
* the draw method. But wait, there's more: being an electronic picture, it
* can be changed. You can set it to black-and-white display and back to
* colors (only after it's been drawn, of course).
*
* This class was written as an early example for teaching Java with BlueJ.
*
* @author Michael Kölling and David J. Barnes
* @version 2011.07.31
*/
public class DZFlag
{
private MyRectangle greenRectangle;
private MyRectangle whiteRectangle;
private MyRectangle frame;
private MyRectangle poteau;
private Circle redCircle;
private Circle whiteCircle;
private Arc arc;
private Star star;
/**
* Constructor for objects of class Picture
*/
public DZFlag()
{
// nothing to do... instance variables are automatically set to null
}
/**
* Draw this picture.
*/
public void draw()
{
poteau = new MyRectangle();
poteau.makeVisible();
poteau.changeSize(10,400);
poteau.changeColor("blue");
poteau.moveHorizontal(-280);
poteau.moveVertical(-100);
frame = new MyRectangle();
frame.changeColor("black");
frame.makeVisible();
frame.changeSize(200,150);
frame.moveHorizontal(-270);
frame.moveVertical(-100);
greenRectangle = new MyRectangle();
greenRectangle.changeColor("green");
greenRectangle.makeVisible();
greenRectangle.changeSize(95,140);
greenRectangle.moveHorizontal(-265);
greenRectangle.moveVertical(-95);
whiteRectangle = new MyRectangle();
whiteRectangle.changeColor("white");
whiteRectangle.makeVisible();
whiteRectangle.changeSize(95,140);
whiteRectangle.moveHorizontal(-170);
whiteRectangle.moveVertical(-95);
redCircle = new Circle();
redCircle.makeVisible();
redCircle.changeColor("red");
redCircle.changeSize(75);
redCircle.moveHorizontal(-128);
redCircle.moveVertical(-35);
whiteCircle = new Circle();
whiteCircle.makeVisible();
whiteCircle.changeColor("white");
whiteCircle.changeSize(60);
whiteCircle.moveHorizontal(-110);
whiteCircle.moveVertical(-27);
arc = new Arc();
arc.makeVisible();
arc.changeColor("green");
arc.changeSize(50,55,90,180);
arc.moveHorizontal(-115);
arc.moveVertical(-24);
star = new Star();
star.makeVisible();
star.changeSize(12);
star.moveHorizontal(-229);
star.moveVertical(-107);
}
}