CS 310, Object-Oriented Programming with Java

Quiz 13, 24 April 2008


  1. A UI designer wants to layout three components on the diagonal.

    a ui layout

    Describe the minimum number of layout managers needed to get this design.


    A grid manager set up with three rows and columns will do the job. (Grid Layout, 350 (7th ed.) or 373 (8th ed.))

    The answers, in no particular order:

    1. 3. One for the frame, one for the lines [?], one for the square.

    2. There will need to be a screen layout manager and three managers for the components. 4 minimum.

    3. Three: north + left; center + center; south + right.

    4. Two, one to create an initial square, and a second to accept coordinates and a copy of the first manager.

    5. At the very least, a 3-row grid would be needed as well as 3 JPanels and the 3 components that are to be displayed, so all that would be needed is a single grid layout manager.

    6. You would need 4 panels. One for each of the components then another to place them in. Then you would place the outer most into a frame. A single layout manager would work for this layout.

    7. The minimum number of layout managers is 3. One for every box.

    8. 3 box layouts and one border layout.

    9. One, by using the grid bag, you can state each component's relation to on another.

    10. You only need one layout manager with can through variables be used to do all 3 components.

    11. A single layout manager can be used with logic to add a new component to the (x, y) coordinates of the preceding button's lower right corner.

    12. One layout manager could be used to get the design above.

    13. The number of layout needed are three. One for each box.

  2. What's the difference between a mnemonic and an accelerator?


    A mnemonic is a keystroke that selects a menu item when the menu is being displayed. An accelerator selects a menu item without having to display the associated menu. (Keyboard Mnemonics and Accelerators, 413 (7th ed.) or 413 (8th ed.)).

    The answers, in no particular order:

    1. A mnemonic won't do things as fast as an accelerator.

    2. A mnemonic has to do with menus whereas an accelerator has to deal

    3. An accelerator is a keyboard shortcut (usually triggered by something akin to Ctrl-V), and a mnemonic is a similar keyboard shortcut that can be used to access different menus, submenus, and menu items (such as Alt to open the menus, F to open the File menu, and P to print).

    4. The mnemonic simply remembers the actions of an accelerator and an accelerator contains the actual actions.

    5. Accelerators are more efficient than mnemonics.

    6. A mnemonic is simply a very fast method built in to Java, whereas a accelerator makes use of an imported library for efficiency.

    7. A mnemonic is used to call objects by class name and an accelerator decides what object takes [?] priority [?].

    8. A mnemonic is a component that doesn't do anything in a MVC. An accelerator makes sure to resize all the components in a textfile.

    9. Mnemonics are short cuts within applications on the menu. Accelerators are other shortcuts within those applications but not located on the menu bar.

    10. A mnemonic is a shortcut key for an item in a menu bar (save), while an accelerator is a shortcut key within other components (pressing “d” instead of clicking a “delete” button).

    11. A mnemonic is more of a shortcut for the developer to make [?] nice [?] graphics whereas the accelerator works with the hardware to take the loud off the CPU.

    12. A mnemonic allows you to handle components by a different name, and an accelerator will lay out the code for using a default component.

    13. An accelerator responds to keystrokes instantly while a mnemonic responds to keystrokes only when the corresponding menu is active.


This page last modified on 24 April 2008.