Answers to Self-Review Exercises

22.1

a) JMenu.

b) addSeparator.

c) stateChanged, ChangeListener.

d) anchor.

22.2

a) False. A JFrame does not require any menus.

b) False. The variable fill belongs to the GridBagConstraints class.

c) True.

d) True.

22.3

a) JMenubar should be JMenuBar.

b) The first argument to the constructor should be SwingConstants.HORIZONTAL or SwingConstants.VERTICAL, and the keyword new must be used after the = operator. Also, the minimum value should be less than the maximum and the initial value should be in range.

c) The constant should be either BOTH, HORIZONTAL, VERTICAL or NONE.

d) paintcomponent should be paintComponent, and the method should call super.paintComponent(g) as its first statement.

e) The JFrame’s setSize ...

Get Java™ How To Program (Early Objects), Tenth Edition 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.