Aid needed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JavanoobX
    New Member
    • Mar 2009
    • 5

    Aid needed

    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:
    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();
    }
    }
    Last edited by pbmods; Mar 2 '09, 12:20 AM. Reason: Added CODE tags.
  • JavanoobX
    New Member
    • Mar 2009
    • 5

    #2
    Seriously no one can help me out? I cannot find how to reports the dimensions, color, or the size of the box when i click

    Comment

    • JavanoobX
      New Member
      • Mar 2009
      • 5

      #3
      ok i fixed it some, but i keep getting an error saying ')' needed
      Code:
      public void onMousePress(Location point){
          clickPoint = point;
          if(bockz.contains(Location clickPoint) ){
              System.out.println("Height " + bockz.getHeight());
              System.out.println("Width" + bockz.getWidth());
              System.out.println("X " + bockz.getX());
              System.out.println("Y " + bockz.getY());
      }

      Comment

      • JavanoobX
        New Member
        • Mar 2009
        • 5

        #4
        Ok so i figured it out, but i cant get it to display on the panel, it comes up in the terminal

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by JavanoobX
          Ok so i figured it out, but i cant get it to display on the panel, it comes up in the terminal
          Yes, that's what the System.out.prin tln() method does: print to the console. Define a few labels containing the text you want to display and add those labels to your panel. Or use a JTextArea and make that component display the text that you want to be shown.

          kind regards,

          Jos

          Comment

          Working...