Bar chart
import javax.swing.*;
public class OpinionPolls extends JFrame{
JLabel questionLabel = new JLabel("Who will win the World Cup?:");
JRadioButton option1 = new JRadioButton("Brazil");
JRadioButton option2 = new JRadioButton("England");
JRadioButton option3 = new JRadioButton("Germany");
JRadioButton option4 = new JRadioButton("Italy");
JButton voteButton = new JButton ("Vote");
public OpinionPolls() {
super ("Opinion Polls");
setSize(500, 500); //size of window in pixels
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ButtonGroup group = new ButtonGroup();
group.add(option1);
group.add(option2);
group.add(option3);
group.add(option4);
JPanel commandPane = new JPanel();
BoxLayout vertical = new BoxLayout (commandPane,
BoxLayout.Y_AXIS);
commandPane.setLayout(vertical);
commandPane.add(questionLabel);
commandPane.add(option1);
commandPane.add(option2);
commandPane.add(option3);
commandPane.add(option4);
commandPane.add(voteButton);
add(commandPane);
setVisible(true);
}
public static void main(String[] arguments){
OpinionPolls be = new OpinionPolls();
}
}
Can someone please urgently tell me what code i should add to this so that when a choice is highlighted and the vote button is pressed a bar chart appears. i know i need to import java.awt.event.*;and
import java.awt.*; and i no i need to use action listener) All help is welcome. Thanks.

