Exercise 1: Using Java Online Documentation

CS 116

Aug. 28, 2002

  1. Look up the Frame class. Construct a Frame object called myFrame with a title ``My first frame.''

    The frame class inherits the method setSize(int width, int height) from the Component class which can be used to change the size of the Frame. Use this method to change the size of myFrame to a width of 100 and a height of 200.

    The Frame class inherits the method setVisible(boolean b) from the Component class which allows us to make the Frame visible or not depending on whether we set b to true or false. Use this method to make myFrame visible.

    Look up the method setLocation and use this method to move the Frame on the screen to position (10,20).

  2. Look up the Color class. Construct a Color object called myColor with a red value of 10, a green value of 100, and a blue value of 50. How would you make a brighter or darker version of this color?

  3. Look up the Button class. Construct a Button object called myButton with a label ``Push me.'' How would you change the label on myButton to ``Push me, again''?

  4. Look up the Graphics class. Construct a Graphics object called g. How would you draw a line that starts at point (10,20) and ends at point (50,60) in the graphics object?



Thomas P. Kelliher
Mon Aug 26 15:55:00 EDT 2002
Tom Kelliher