Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Bar chart

I am new to Java and so far i have done the following code and now im stuck

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.
[1666 byte] By [Trisha1] at [2007-11-11 8:49:36]
# 1 Re: Bar chart
1. implement the interface 'ActionListener'
2. write the actionPerformed(ActionEvent) method, which updates your bar graph
3. voteButton.addActionListener(this);
Phaelax at 2007-11-11 22:34:14 >