Problem 5
Determine whether each statement is true or \(f a l\) se. If false , explain why. a) Only one layout manager can be used per Container. b) GUI components can be added to a Container in any order in a BorderLayout. c) JRadioButtons provide a series of mutually exclusive options (i.e., only one can be true at a time) d) Graphics method setFont is used to set the font for text fields. e) A JList displays a scrollbar if there are more items in the list than can be displayed. f) A Mouse object has a method called mouseDragged.
Problem 6
Determine whether each statement is true or false. If false, explain why. a) A JPanel is a JComponent. b) A JPanel is a Component. c) A JLabel is a Container. d) A JList is a JPane7. e) An AbstractButton is a JButton. f) A JTextField is an Object. g) ButtonGroup is a subclass of JComponent.
Problem 7
Find any errors in each of the following lines of code, and explain how to correct them. a) import javax.swing. JFrame b) panelobject. GridLayout (8,8)\(; / /\) set GridLayout c) container.setLayout ( new F1 owLayout( F1owLayout. DEFAULT ) ); d) container.add ( eastButton, EAST ); // BorderLayout
Problem 12
Write a temperature conversion application that converts from Fahrenheit to Celsius. The Fahrenheit temperature should be entered from the keyboard (via a JTextField). A JLabel should be used to display the converted temperature. Use the following formula for the conversion: \\[\text { Celsius }=\frac{5}{9} \times(\text { Fahrenheit }-32)\\]
Problem 15
Write an application that plays "guess the number" as follows: Your application chooses the number to be guessed by selecting an integer at random in the range \(1-1000 .\) The application then displays the following in a label: I have a number between 1 and 1000 . Can you guess my number? Please enter your first guess. A JTextField should be used to input the guess. As each guess is input, the background color should change to either red or blue. Red indicates that the user is getting "warmer," and blue indicates that the user is getting "colder." A JLabel should display either "Too High" or "Too Low" to help the user zero in on the correct answer. When the user gets the correct answer, "Correct!" should be displayed, and the JTextField used for input should be changed to be uneditable. A JButton should be provided to allow the user to play the game again. When the JButton is clicked, a new random number should be generated and the input JTextField changed to be editable.