Exercises

25.4

(Fill-in-the-Blanks) Fill in the blanks in each of the following statements:

  1. A JMenuItem that is a JMenu is called a(n).

  2. Method attaches a JMenuBar to a JFrame.

  3. Container class has a default BoxLayout.

  4. A(n) manages a set of child windows declared with class JInternalFrame.

25.5

(True or False) State whether each of the following is true or false. If false, explain why.

  1. Menus require a JMenuBar object so they can be attached to a JFrame.

  2. BoxLayout is the default layout manager for a JFrame.

  3. JApplets can contain menus.

25.6

(Find the Code Errors) Find the error(s) in each of the following. Explain how to correct the error(s).

  1. x.add( new JMenuItem( “Submenu Color” ) ); // create submenu

Get Java How to Program (early objects), 9/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.