I'm trying to create a application for an online class. They don't offer much help. It deals with buttongroups. The text book only has half a page talking about it but no code examples.
I'm not sure how to do the public void actionPerformed with buttongroups or if the rest of the code is completely right.
Please feel free to insult me if needed.
Code:import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent.*;
import java.awt.event.ActionListener.*;
public class JMyNewHome3 extends JFrame implements ActionListener
{
int house1 = 100000;
int house2 = 120000;
int house3 = 180000;
int house4 = 250000;
int bedroom2 = 10500;
int bedroom3 = 21000;
int bedrrom4 = 31500;
int car0 = 0;
int car1 = 7775;
int car2 = 15500;
int car3 = 23325;
int car4 = 31100;
ButtonGroup group1 = new ButtonGroup() ;
JCheckBox house1 = new JCheckBox("Aspen", false);
JCheckBox house2 = new JCheckBox("Brittany", false) ;
JCheckBox house3 = new JCheckBox("Colonial", false) ;
JCheckBox house4 = new JCheckBox("Dartmoor", false) ;
ButtonGroup group2 = new ButtonGroup() ;
JCheckBox bedroom2 = new JCheckBox("2 Bedroom", false) ;
JCheckBox bedroom3 = new JCheckBox("3 Bedroom", false) ;
JCheckBox bedroom4 = new JCheckBox("4 Bedroom", false) ;
ButtonGroup group3 = new ButtonGroup() ;
JCheckBox car0 = new JCheckBox("No Garage", false) ;
JCheckBox car1 = new JCheckBox("1 Car", false) ;
JCheckBox car2 = new JCheckBox("2 Car", false) ;
JCheckBox car3 = new JCheckBox("3 Car", false) ;
public JMyNewHome3()
{
super("My New Home");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
add(house1) ;
add(house2) ;
add(house3) ;
add(house4) ;
add(bedroom2) ;
add(bedroom3) ;
add(bedroom4) ;
add(car0) ;
add(car1) ;
add(car2) ;
add(car3) ;
house1.addActionListener(this);
house2.addActionListener(this);
house3.addActionListener(this);
house4.addActionListener(this);
bedroom2.addActionListener(this);
bedroom3.addActionListener(this);
bedroom4.addActionListener(this);
car0.addActionListener(this);
car1.addActionListener(this);
car2.addActionListener(this);
car3.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
Object source = event.getSource();
int select = event.getStateChange();
if
}
public static void main(String[] args)
{
JMyNewHome3 aFrame = new JMyNewHome3();
final int WIDTH = 300;
final int HEIGHT = 250;
aFrame.setSize(WIDTH, HEIGHT);
aFrame.setVisible(true);
}
}

