Reference no: EM1371494
The files StyleOptions.java and StyleOptionsPanel.java are from Listings 5.22 and 5.23 of the text (Java Software Solutions 6th Edition - Lewis & Loftus - with a couple of slight changes-an instance variable fontSize is used rather than the literal 36 for font size and the variable style is an instance variable rather than local to the itemStateChanged method). The program demonstrates checkboxes and ItemListeners. In this exercise you will add a set of three radio buttons to let the user choose among three font sizes. The method of adding the radio buttons will be very similar to that in the QuoteOptionsPanel class (Listing 5.25 of the text). Before modifying the program compile and run the current version to see how it works and study the QuoteOptionsPanel example.
Do the following to add the radio buttons to the panel:
1. Declare three objects small, medium, and large of type JRadioButton.
2. Instantiate the button objects labeling them "Small Font," "Medium Font," "Large Font." Initialize the large font button to true. Set the background color of the buttons to cyan.
3. Instantiate a button group object and add the buttons to it.
4. Radio buttons produce action events so you need an ActionListener to listen for radio button clicks. The code you need to add to actionPerformed will be similar to that in the QuoteListener in Listing 5.25. In this case you need to set the fontSize variable (use 12 for small, 24 for medium, and 36 for large) in the if statement, then call the setFont method to set the font for the saying object. (Note: Instead of adding an ActionListener you could use the current ItemListener and add code to check to see if the source of the event was a radio button.)
5. In StyleOptionsPanel() add the ItemListener object to each button and add each button to the panel.
6. Compile and run the program. Note that as the font size changes the checkboxes and buttons re-arrange themselves in the panel. You will learn how to control layout later in the course.
What current is required in the windings
: A racing car travels with a constant tangential speed of 75 m/s around a circular track with a radius 625 m. Find (a) the magnitude of the car's total acceleration and (b) the direction of its total acceleration relative to the radial direction.
|
What is the grocery cart final speed
: A 75-kg trqampoline artist jumps vertically upward from the top of a platform with a speed of 5.00 m/s. (a) how fast is he going as he lands on the trampoline 3.0m below? (b) If the trampoline behaves like a spring of spring constant 5.2 x 10^4 N/..
|
Can unrealistic assumptions provide useful outcomes
: When do assumptions made in conjunction with economic theorizing have to be realistic. Can unrealistic assumptions provide useful outcomes.
|
What is the instantaneous power delivered to the wheel
: Express the power in terms of some or all of the variables given in the problem introduction.
|
Instantiate button group object-add radio buttons to panel
: Do the following to add radio buttons to panel: Declare three objects small, medium, and large of type JRadioButton. Instantiate button group object and add buttons to it.
|
Explain how your expansionary acts would operate economy
: Write an explanation for an interrogatory senator outlining Explain how your expansionary acts would operate and illustrate what would be effects on economy.
|
Personal barriers in life
: When a discussion arises regarding overcming barriers, there must be a detailed assessment of oneself to determine the best course of action to take in achieving those goals. Explain.
|
Explain the sec attempts to protect investors
: Explain The SEC attempts to protect investors who are purchasing newly issued securities by making sure that the information put out by a company
|
Find out the time interval
: A pitcher throws a curveball that reaches the catcher in 0.59 s. The ball curves because it is spinning at an average angular velocity of 380 rev/min on its way to the catcher's mitt. What is the angular displacement of the baseball as it travels ..
|