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 a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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