GUI Midterm

Spring 2011

  1. This exam is closed-note, closed-book. However you may use a one page "cheat" sheet that you have prepared in advance. Your "cheat" sheet may contain notes on both the front and the back.
  2. You must answer all of the questions.
  3. Use the exam pages to answer all the questions. There should be 10 questions.
  4. All electronic devices must be turned off.
  5. Good luck!

  1. (3 points) Draw a line from each item in the left column to its preferred usage in the right column:
    sans-serif font                       computer display
    serif font                            computer program text
    typewriter (mono-spaced) font         printed document

  2. (3 points) Draw a line from each item in the left column to the object/person in the right column that most commonly uses it:
    CMY color model                       computer program
    RGB color model                       printer
    HSV color model                       artist

  3. (8 points) For the following questions, circle the best answer:

    1. Humans are 10 times more sensitive to variations in this item
      1. hue
      2. saturation
      3. brightness

    2. Which two of the following colors are easiest for the eye to resolve? You need to circle two answers.
      1. red
      2. green
      3. blue
      4. yellow

    3. The human brain receives the bulk of its sensory input from the following channel
      1. visual
      2. audio
      3. taste
      4. smell

    4. The following type of object model draws unfilled images using mathematical equations or by connecting a series of points:
      1. region model
      2. stroke model
      3. pixel model
      4. grayscale model

  4. (20 points) For each of the questions below, select the best answer from the following list:
    model         observer        paintComponent  ascent     bundling
    view          strategy        anti-aliasing   descent    pen
    controller    iterator        key framing     baseline   brush
    listener      repaint         animation       leading    graphics
    adapter       revalidate      simulation      font       region model
    stroke model  pixel model     grayscale       delegation color model
    interpolation draw            paint           
    1. __________________ Java method that you call when you want to schedule a paint event.
    2. __________________ Java method that you call when you want to invoke a JPanel's layout manager to re-layout its components.
    3. __________________ In the MVC model, the portion of the application that stores the application's state information.
    4. __________________ In the MVC model, the portion of the application that performs event handling.
    5. __________________ A technique that creates the illusion of movement by quickly replacing on the computer screen with a new image that is similar to the previous image, but shifted slightly.
    6. __________________ Technique for drawing pixels in gray-scale or less color intensity at the edges of an image to reduce the jagged quality that can be produced by discrete pixels.
    7. __________________ The name of the design pattern used by the model to notify views of changes to the model.
    8. __________________ The distance between the baseline and the highest extent of any character in the font.
    9. __________________ A method of event-handling used by C# whereby 1) an event designates a variable to handle events that it generates, 2) subscribers register callback methods with this variable, and 3) an event invokes each of the callback methods by "calling" the variable as if it were a function.
    10. __________________ A drawing technique by which the drawing command takes a pointer to a shape and a pointer to an object that represents a set of visual attributes, such as color and thickness, and draws the shape by combining the geometric information in the shape with the geometric information in the object.
  5. (10 points) Answer true or false to the following questions:

    1. _______________ It is okay to call paintComponent directly from an event handler.

    2. _______________ The CMY color model is an additive/reflective color model.

    3. _______________ A font's pixel height is always the same as its point size

    4. _______________ A box layout manager respects both an object's preferred size and its maximum size

    5. _______________ It is better to prevent the user from making an error than to provide outstanding error messages

    6. _______________ A flow layout manager should be used to vertically stack widgets

    7. _______________ Text strings are difficult to center vertically.

    8. _______________ Java's event listener model is based on the observer pattern.

    9. _______________ It is distracting to provide feedback to the user while the user performs an operation and hence feedback should only be provided to the user once the user has completed the operation.

    10. _______________ Syntactic feedback refers to feedback that is provided after an operation has been completed to show the user the result of the operation.

  6. (10 points) Based on the course notes and lecture, answer "yes" or "no" for whether each of the following scenarios represents a good use of animation:

    1. _____________ Showing planetary bodies moving around a star.

    2. _____________ Flying in bullet points on a power point slide

    3. _____________ Showing the minute and hour "hands" moving in an analog clock.

    4. _____________ Advertising 5 separate items on a web-site by having them all flash simultaneously.

    5. _____________ Drawing a user's attention to an alert box by flashing it for 2-3 seconds and then stopping the flashing.
  7. (12 points) Which Java layout manager is the best choice for each of the following situations. Please limit yourself to the following layout managers:


    1. ______________ You want to lay out a vertical stack of labeled text fields. The labels should be left-aligned with each other and vertically centered with the text fields. The text fields should be left-aligned with each other. If the window is re-sized, the text fields should get all the additional horizontal space.

    2. ______________ You want to use absolute positioning for each widget and you do not want the widget's location or size to vary if the window is resized.

    3. ______________ You want to horizontally lay out a set of text justification icons using their natural size, no matter how big the window gets
    4. ______________ You want to create a top-level layout with an application window in the center and tool bars arrayed around the boundaries of the application window.

    5. ______________ You want to use an IDE to lay out a set of widgets and you want the widget's size to vary in a reasonable way when the window is resized.

    6. ______________ You want a horizontal set of command buttons whose spacing should be controlled with rigid areas and glue objects

  8. (15 points) Each of the following questions will ask you to collect some type of data or provide some type of operation to the user. For each question, select the most appropriate widget to use for that question based on the material you have been presented in this course. You should select each answer from the following list of widgets:
    	slider      radio buttons      text field
            menu/list   check boxes        command buttons

    1. ________________ You want the user to enter their checking account number, which is an 8 digit number.

    2. ________________ You want the user to enter the month for which they want to travel and screen real estate is at a premium.

    3. ________________ You want the user to select from among possible toppings for a pizza. The user is allowed to select multiple toppings and you want the user to be able to easily see all the toppings at once. Screen real estate is abundant.

    4. ________________ You want the user to assign a performance rating of Excellent, Good, Average, Mediocre, and Failing

    5. ________________ You want to display a pallette of text justification icons, with the options being left justify, center, and right justify.

  9. (8 points) In two sentences or less, describe the problem associated with each of the following "bugs":

    1. Forgetting to call super.paintComponent
    2. Forgetting to restore the Graphics object to its original state on exiting paintComponent.
    3. Forgetting to request the focus when you add a key listener to a JComponent.
    4. Forgetting to call pack after the preferred size of a JComponent has changed.

  10. (11 points) On the next page, sketch the window that is drawn by the following code. Where there are fixed distances between objects, indicate what those fixed distances are. Assume that the window being drawn is much wider and taller than the buttons that it contains (i.e., I want you to show me that you know what Horizontal and VerticalGlue do when the window is bigger than the elements it is displaying).
        JButton b1 = new JButton("Button1");
        JButton b2 = new JButton("Button2");
        JButton b3 = new JButton("Button3");
        JButton b4 = new JButton("Button4");
        JButton b5 = new JButton("Button5");
        // set layout for the top level container
        setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
        Box buttonGroup1 = Box.createHorizontalBox();
        Box buttonGroup2 = Box.createHorizontalBox();
        Box buttonGroup3 = Box.createHorizontalBox();
        buttonGroup3.add(Box.createRigidArea(new Dimension(20, 0)));
        add(Box.createRigidArea(new Dimension(0,5)));
        add(Box.createRigidArea(new Dimension(0,5)));