I have no clue of how to make a program report the dimensions and location of the box as well as the components of the color (red, blue, and green)
when the mouse is clicked.
Here is the code:
when the mouse is clicked.
Here is the code:
Code:
import objectdraw.*;
import java.awt.*;
//Program that creates a filledrect that changes color upon entrance of the panel, upon exit, it clears.
//Upon re-entry, it will create a new centered box that changes colors.
//Occasionally it will make another box.
public class Box extends FrameWindowController{
private FilledRect bockz;
private RandomIntGenerator heightz;
private RandomIntGenerator widthz;
private RandomIntGenerator colur;
private int colure;
private int shade;
private int tint;
private int sides;
private int tops;
private Text boxLabel;
// the coordinate values displayed
private Text vertLabel, horizLabel;
public void onMouseEnter(Location point){
heightz = new RandomIntGenerator(20,120); //Creates the vertical sides lengths
widthz = new RandomIntGenerator(20,120); //Creats the horizontal side lengths
colur = new RandomIntGenerator(0,225);
tops = widthz.nextValue();
sides = heightz.nextValue();
bockz = new FilledRect(canvas.getWidth()/2,canvas.getHeight()/2,sides,tops,canvas);
colure = colur.nextValue();
shade = colur.nextValue();
tint = colur.nextValue();
bockz.setColor(new Color(colure,shade,tint));
}
public void onMousePress(Location point){
}
public void onMouseExit(Location point){
canvas.clear();
}
}
Comment