Instantiate button group object-add radio buttons to panel

Assignment Help Programming Languages
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.

Reference no: EM1371494

Questions Cloud

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 ..

Reviews

Write a Review

Programming Languages Questions & Answers

  Write pseudocode for finding grade of a student

Write pseudocode for finding grade of a student given his/her total score. The program must display a grade of A if the score is above 85, a B if it is between 85 and 75, a C.

  Write function that takes array of positive integers

Write a function that takes an array of positive integers and the size of the array, and returns the average (type float) of the values.

  Program to calculate the electricity bill

Write a program to calculate the electricity bill. The rates of electricity per unit are as follows: If the units consumed are equal or less than 100, then the cost is Rs 8/- per unit.

  Object-oriented analysis and design

Object-Oriented Analysis and Design,  PART B-object-oriented design involves the steps 13-18:

  Creating form which analyzes poker hand entered by user

To observe behavior of Sub Procedures, draw a Form which analyzes a poker hand entered by user and displays the type of hand.

  Explaining handles clause of sub procedure

You are asked to design a form with a textbox named txtQty, a label named lblStatus, and a button named btnGetStatus. What will be Handles clause at the end of sub procedure?

  Write a program to read student data from standard input

Write a program to read student data from standard input, sort it by last name / first name, and print result to standard output.

  Application to print the sum of cubes

Write down the application to print the sum of cubes. Prompt for and read two integer values and print sum of each value raised to third power.

  Design fraction class to represent numerator and denominator

Design a fraction class. The class should have 2 data members to represent the numerator and denominator. Both of these numbers should obviously be integers.

  Write program to accept name and score of all batsmen

Write a program to accept name and score of all batsmen of a team and print them in the given manner: INPUT:names[]={nam1,nam2,nam3,nam4,nam5,nam6} & scores[]={48,65,73,10,90,84}

  Program which accepts candy name-price per pound

A program which accepts the candy name (for example, "chocolate-covered cherries"), price per pound, and number of pounds sol in average month, and displays item's data only if it is best-selling item.

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd