wow i can't believe i missed that ><
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JMyNewHome extends JFrame
{
public static void main(String[] arg)
{
JMyNewHome window = new JMyNewHome();
window.setVisible(true);
}
JCheckBox aspen = new JCheckBox("Aspen-$100,000");
JCheckBox brittany = new JCheckBox("Brittany-$120,000");
JCheckBox colonial = new JCheckBox("Colonial-$180,00");
JCheckBox dartmoor = new JCheckBox("Dartmoor-$250,000");
JCheckBox twobed = new JCheckBox("2 Bed-$21,000");
JCheckBox threebed = new JCheckBox("3 Bed-$31,500");
JCheckBox fourbed = new JCheckBox("4 Bed-$42,000");
JCheckBox carzero = new JCheckBox("0 Car-$0");
JCheckBox carone = new JCheckBox("1 Car-$7,775");
JCheckBox cartwo = new JCheckBox("2 Car-$15,550");
JCheckBox carthree = new JCheckBox("3 Car-$23,325");
JLabel price = new JLabel("$0.00");
Container contentPane = getContentPane();
/* final int aspen = 100000;
final int brittany = 120000;
final int colonial = 180000;
final int dartmoor = 250000;
final int twobed = 21000;
final int threebed = 31500;
final int fourbed = 42000;
final int carzero = 0;
final int carone = 7775;
final int cartwo = 15550;
final int carthree = 23325;
int price = 0;
*/
public JMyNewHome()
{
setTitle("My New Home");
setLayout(new FlowLayout());
contentPane.add(aspen);
contentPane.add(brittany);
contentPane.add(colonial);
contentPane.add(dartmoor);
contentPane.add(twobed);
contentPane.add(threebed);
contentPane.add(fourbed);
contentPane.add(carzero);
contentPane.add(carone);
contentPane.add(cartwo);
contentPane.add(carthree);
contentPane.add(price);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,150);
ButtonGroup house = new ButtonGroup();
house.add(aspen);
house.add(brittany);
house.add(colonial);
house.add(dartmoor);
ButtonGroup beds = new ButtonGroup();
beds.add(twobed);
beds.add(threebed);
beds.add(fourbed);
ButtonGroup cars = new ButtonGroup();
cars.add(carzero);
cars.add(carone);
cars.add(cartwo);
cars.add(carthree);
ClickButtonListener clickListener = new ClickButtonListener();
aspen.addActionListener(clickListener);
brittany.addActionListener(clickListener);
colonial.addActionListener(clickListener);
dartmoor.addActionListener(clickListener);
twobed.addActionListener(clickListener);
threebed.addActionListener(clickListener);
fourbed.addActionListener(clickListener);
carzero.addActionListener(clickListener);
carone.addActionListener(clickListener);
cartwo.addActionListener(clickListener);
carthree.addActionListener(clickListener);
}
public class ClickButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Object o = e.getSource();
if(o==aspen)
{
if(aspen.isSelected())
{
int hprice = 100000;
}
}
else if(o==brittany)
{
if(brittany.isSelected())
{
int hprice = 120000;
}
}
else if(o==colonial)
{
if(colonial.isSelected())
{
int hprice = 180000;
}
}
else if(o==dartmoor)
{
if(dartmoor.isSelected())
{
int hprice = 250000;
}
}
else if(o==twobed)
{
if(twobed.isSelected())
{
int bprice = 21000;
}
}
else if(o==threebed)
{
if(threebed.isSelected())
{
int bprice = 31500;
}
}
else if(o==fourbed)
{
if(fourbed.isSelected())
{
int bprice = 42000;
}
}
else if(o==carzero)
{
if(carzero.isSelected())
{
int cprice = 0;
}
}
else if(o==carone)
{
if(carone.isSelected())
{
int cprice = 7775;
}
}
else if(o==cartwo)
{
if(cartwo.isSelected())
{
int cprice = 15550;
}
}
else if(o==carthree)
{
if(carthree.isSelected())
{
int cprice = 23325;
}
}
price.setText(+hprice+bprice+cprice);
}
}
}
ugh now the program won't recognise my h/b/cprice
--------------------Configuration: <Default>--------------------
K:\CompSci\Projects\JMyNewHome.java:177: error: cannot find symbol
price.setText(+hprice+bprice+cprice);
^
symbol: variable hprice
location: class JMyNewHome.ClickButtonListener
K:\CompSci\Projects\JMyNewHome.java:177: error: cannot find symbol
price.setText(+hprice+bprice+cprice);
^
symbol: variable bprice
location: class JMyNewHome.ClickButtonListener
K:\CompSci\Projects\JMyNewHome.java:177: error: cannot find symbol
price.setText(+hprice+bprice+cprice);
^
symbol: variable cprice
location: class JMyNewHome.ClickButtonListener
3 errors
Process completed.
im not quite sure where to put it...