#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    Canada
    Posts
    12
    Rep Power
    0

    Help simple solution suspected


    Hi. In eclipse when I run a program my applet window opens really small on my mac.

    Example code

    import acm.graphics.*;
    import acm.program.*;

    public class centeredText extends GraphicsProgram {

    public void run() {

    GLabel label = new GLabel("CS106A rocks my socks!");
    label.setFont("SansSerif-28");
    double x = (getWidth() - label.getWidth()) / 2;
    double y = (getHeight() + label.getAscent()) / 2;
    label.setLocation(x, y);
    add(label);
    }
    }

    this makes my label appear off the screen to the left and right because my window always opens small. Please help!!!

    Edit *

    I have went into run configurations and changed the (x) parameters and it works, how do I set that as defaults when I create a new class.

    THX
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    3
    Rep Power
    0
    you may try to just add a size statement for your gui such as, setSize (Horizontal, Vertical) . the numbers will be in pixels. It works in my compiler so not sure if the statements are that similar, but worth a try if still stuck on it.

IMN logo majestic logo threadwatch logo seochat tools logo