Presentation is loading. Please wait.

Presentation is loading. Please wait.

A First Look at GUI Applications Part IV: Radio Buttons 1.

Similar presentations


Presentation on theme: "A First Look at GUI Applications Part IV: Radio Buttons 1."— Presentation transcript:

1 A First Look at GUI Applications Part IV: Radio Buttons 1

2 Contents A.What is Radio Button? B.Metric Converter Example 2

3 A. What is Radio Button?  Radio buttons allow the user to select one choice from several possible options  The JRadioButton class is used to create radio buttons  JRadioButton constructors: JRadioButton(String text) JRadioButton(String text, boolean selected)  Method isSelected() is for checking selection  An instance of the ButtonGroup class is used to group radio buttons 3

4 B. Metric Converter Example  Reuse the kilometer converter example  Convert the distance to feet: 1 kilometer = 3281 feet  Convert the distance to inches: 1 kilometer = 39370 inches  The new interface is as below: 4

5 B. Metric Converter Example 1.Enhancing the Design 2.Enhancing the KilometerConverterTest Class 3.Enhancing the KilometerConverter Class 4.Creating the Interface 5

6 1. Enhancing the Design 6

7 2. Enhancing the KilometerConverterTest Class 7

8 3. Enhancing the KilometerConverter Class 8

9 4. Creating the Interface 4.1. Creating the Activating Class 4.2. Creating the Window 9

10 4.1. Creating the Activating Class  Class name: MetricConverterProgram  The window’s basic properties: Class name: MetricConverter Title: Metric Converter Size: 400 x 100 10

11 4.2. Creating the Window 4.2.1. Generating the Window 4.2.2. Creating the Components 4.2.3. Grouping the Radio Buttons 4.2.4. Converting to Miles 4.2.5. Converting to Feet 4.2.6. Converting to Inches 11

12 4.2.1. Generating the Window 12

13 4.2.2. Creating the Components  Use FlowLayout for this case 13

14 4.2.3. Grouping the Radio Buttons  Only one radio button is chosen at the same time 14

15 4.2.4. Converting to Miles 15

16 4.2.5. Converting to Feet 16

17 4.2.6. Converting to Inches 17


Download ppt "A First Look at GUI Applications Part IV: Radio Buttons 1."

Similar presentations


Ads by Google