There is something wrong with this Java program but I do not know what it is. can someone help   2 import java.awt.*;  3 import javax.swing.*;  4 import java.awt.event.*;  5 import java.awt.Color;  6  7  8 class Radiobutton extends JFrame {  9 10    11    JRadioButton jRadioButton1;  12    JRadioButton jRadioButton2; 13    JButton jButton; 14    ButtonGroup G1; 15    JLabel L1; 16    17    public Radiobutton() 18    { 19       this.setLayout(null); 20       jRadioButton1 = new JRadioButton(); 21       jRadioButton2 = new JRadioButton(); 22       jButton = new JButton("Click"); 23       G1 = new ButtonGroup(); 24       L1 = new JLabel("Qualification"); 25       26       jRadioButton1.setText("Under-Graduate"); 27       jRadioButton2.setText("Graduate"); 28       29       jRadioButton1.setBounds(120, 30, 120, 50); 30       jRadioButton2.setBounds(250, 30, 80, 50); 31       jButton.setBounds(125, 90, 80, 30); 32       L1.setBounds(20, 30, 150, 50); 33 34       this.add(jRadioButton1); 35       this.add(jRadioButton2);  36       this.add(jButton); 37       this.add(L1); 38 39       G1.add(jRadioButton1); 40       G1.add(jRadioButton2); 41 42       jButton.addActionListener(new ActionListener() { 43 44 45          public void actionPerformed(ActionEvent e) { 46 47             String qual = " "; 48 49             if (jRadioButton1.isSelected()) { 50 51                qual = "Under-Graduate"; 52             } 53 54             else if (jRadioButton2.isSelected()) { 55 56                qual = "Graduate"; 57             } 58             else { 59 60                qual = "NO Button selected"; 61             } 62 63             JOptionPane.showMessageDialog(Radiobutton.this, qual); 64          } 65       }); 66    } 67 } 68 69 class RadioButton { 70 71    public static void main(String args[]) { 72       Radiobutton f = new Radiobutton(); 73       f.setBounds(100, 100, 400, 200);  74       f.setTitle("RadioButtons"); 75       f.getContentPane().setBackground(Color.LIGHT_GRAY); 76       f.setVisible(true); 77    } 78 }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

There is something wrong with this Java program but I do not know what it is. can someone help 


 2 import java.awt.*;
 3 import javax.swing.*;
 4 import java.awt.event.*;
 5 import java.awt.Color;
 6
 7
 8 class Radiobutton extends JFrame {
 9
10   
11    JRadioButton jRadioButton1; 
12    JRadioButton jRadioButton2;
13    JButton jButton;
14    ButtonGroup G1;
15    JLabel L1;
16   
17    public Radiobutton()
18    {
19       this.setLayout(null);
20       jRadioButton1 = new JRadioButton();
21       jRadioButton2 = new JRadioButton();
22       jButton = new JButton("Click");
23       G1 = new ButtonGroup();
24       L1 = new JLabel("Qualification");
25      
26       jRadioButton1.setText("Under-Graduate");
27       jRadioButton2.setText("Graduate");
28      
29       jRadioButton1.setBounds(120, 30, 120, 50);
30       jRadioButton2.setBounds(250, 30, 80, 50);
31       jButton.setBounds(125, 90, 80, 30);
32       L1.setBounds(20, 30, 150, 50);
33
34       this.add(jRadioButton1);
35       this.add(jRadioButton2); 
36       this.add(jButton);
37       this.add(L1);
38
39       G1.add(jRadioButton1);
40       G1.add(jRadioButton2);
41
42       jButton.addActionListener(new ActionListener() {
43
44
45          public void actionPerformed(ActionEvent e) {
46
47             String qual = " ";
48
49             if (jRadioButton1.isSelected()) {
50
51                qual = "Under-Graduate";
52             }
53
54             else if (jRadioButton2.isSelected()) {
55
56                qual = "Graduate";
57             }
58             else {
59
60                qual = "NO Button selected";
61             }
62
63             JOptionPane.showMessageDialog(Radiobutton.this, qual);
64          }
65       });
66    }
67 }
68
69 class RadioButton {
70
71    public static void main(String args[]) {
72       Radiobutton f = new Radiobutton();
73       f.setBounds(100, 100, 400, 200); 
74       f.setTitle("RadioButtons");
75       f.getContentPane().setBackground(Color.LIGHT_GRAY);
76       f.setVisible(true);
77    }
78 }

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY