//ChoicePanel.java
import java.awt.*;
import java.awt.event.*;

public class ChoicePanel extends Panel implements MouseListener, ActionListener {  //, ItemListener{ 
	
    //public Checkbox h1, h2, h3, h4, h5, h6, c1, c2, c3, c4, c5, c6, f1, f2;
    //public CheckboxGroup hgrid, cgrid, cfield;

    boolean c1, c2, c3, c4, f1, f2;

	private  Label lab1, lab2;
        private  Label magnetico, elettrico;
        
        public int x, y;
        
	public Button information;
        public Button bHnear, bHfar, bHdif, bEnear, bEfar, bEdif, bErad;
        public Panel pHnear = new Panel();
        public Panel pHfar  = new Panel();
        public Panel pHdif  = new Panel();
        public Panel pEnear = new Panel();
        public Panel pEfar = new Panel();
        public Panel pEdif = new Panel();
        public Panel pErad = new Panel();
        
	public Panel ps7 = new Panel();
        public Panel ps8 = new Panel();
        
        public int ypos0, ypos1, ypos2, xpos0, xpos1, xpos2, xpos3;
        private double delta_lambda = 0.01;
        private boolean IsMagnetic = true;
        private static final Color bgcolor = Color.white;
	Trans_State state;
        
	public ChoicePanel(Trans_State state){
		super();
		setLayout(null);
                this.state = state;
                
		setBackground(bgcolor);
		Font labelfont = new Font("SanSerif",Font.BOLD,state.font11);
		
                ypos0 = state.s6;
                ypos1 = state.s45; 
                ypos2 = state.s70;
                xpos0 = state.s66; 
                xpos1 = state.s26;
                xpos2 = state.s200+state.s65;
                xpos3 = state.s250;


		c1 = true;
		c2 = false;
		c3 = false;
		c4 = false;
		f1 = true;
		f2 = false;

		/*
                cgrid = new CheckboxGroup();
                hgrid = new CheckboxGroup();
                cfield = new CheckboxGroup();
                
		c1=new Checkbox("",cgrid,true);
                c2=new Checkbox("",cgrid,false);
                c3=new Checkbox("",cgrid,false);
                c4=new Checkbox("",cgrid,false);
                
                c5=new Checkbox("   Show all ",cgrid,false);
                c6=new Checkbox("   Formulas ",cgrid,false);
                                                
                f1=new Checkbox("Magnetic Field",cfield,true);
                f2=new Checkbox("Electric Field",cfield,false);
                
                magnetico = new Label("Magnetic Field",Label.CENTER);
                elettrico = new Label("Electric Field",Label.CENTER);
                
		add(c1); // Far Field Approximation
		c1.setFont(new Font("SanSerif",Font.PLAIN,state.font12));
		c1.setBackground(bgcolor);
		c1.setForeground(Color.red.darker());
		//c1.setBounds(xpos1,ypos2,state.s23,state.s20);
                c1.setVisible(true);
                
                add(c2); // Exact Solution
		c2.setFont(new Font("SanSerif",Font.PLAIN,state.font12));
		c2.setBackground(bgcolor);
		c2.setForeground(Color.black);
                //c2.setBounds(xpos1,ypos1,state.s23,state.s20);
                c2.setVisible(true);
                
                add(c3); // Exact radial solution - only for Elctric Field
		c3.setFont(new Font("SanSerif",Font.PLAIN,state.font12));
		c3.setBackground(bgcolor);
		c3.setForeground(Color.blue.darker());
		//c3.setBounds(xpos3,ypos2,state.s23,state.s20);
                c3.setVisible(false);
                
                add(c4); // Difference: Exact - Far Field Approximation
		c4.setFont(new Font("SanSerif",Font.PLAIN,state.font12));
		c4.setBackground(bgcolor);
		c4.setForeground(Color.black);
                //c4.setBounds(xpos3,ypos1,state.s23,state.s20);
                c4.setVisible(true);
                
                add(f1);
		f1.setFont(new Font("SanSerif",Font.PLAIN,state.font12));
		f1.setBackground(bgcolor);
		f1.setForeground(Color.blue.darker());
                //f1.setBounds(xpos0,ypos0,state.s120,state.s18);
                
                add(f2);
		f2.setFont(new Font("SanSerif",Font.PLAIN,state.font12));
		f2.setBackground(bgcolor);
		f2.setForeground(Color.red.darker());
                //f2.setBounds(xpos2,ypos0,state.s100,state.s18);
                
                //add(magnetico);
		magnetico.setFont(new Font("SanSerif",Font.PLAIN,state.font14));
		magnetico.setBackground(bgcolor);
                magnetico.setForeground(Color.blue.darker());
                magnetico.setBounds(xpos0,ypos0,state.s120,state.s18);
                
                //add(elettrico);
		elettrico.setFont(new Font("SanSerif",Font.PLAIN,state.font14));
		elettrico.setBackground(bgcolor);
                elettrico.setForeground(Color.red.darker());
                elettrico.setBounds(xpos2,ypos0,state.s100,state.s18);
                */
                if(state.IsMac){
                    bHnear = new Button("\u2714");
                }
                else{
                    bHnear = new Button("\u2713");
                }
                
                bHfar  = new Button("");
                bHdif  = new Button("");
                bEnear = new Button("");
                bEfar  = new Button("");
                bEdif  = new Button("");
                bErad  = new Button("");
                bHnear.setFont(new Font("SanSerif",Font.BOLD,state.font14));
                bHfar.setFont(new Font("SanSerif",Font.BOLD,state.font14));
                bHdif.setFont(new Font("SanSerif",Font.BOLD,state.font14));
                bEnear.setFont(new Font("SanSerif",Font.BOLD,state.font14));
                bEfar.setFont(new Font("SanSerif",Font.BOLD,state.font14));
                bEdif.setFont(new Font("SanSerif",Font.BOLD,state.font14));
                bErad.setFont(new Font("SanSerif",Font.BOLD,state.font14));
                
                bHnear.setBackground(Color.white);
                bHfar.setBackground(Color.white);
                bHdif.setBackground(Color.white);
                bEnear.setBackground(Color.white);
                bEfar.setBackground(Color.white);
                bEdif.setBackground(Color.white);
                bErad.setBackground(Color.white);
                
                bHnear.setForeground(Color.blue);
                bHfar.setForeground(Color.gray);
                bHdif.setForeground(Color.gray);
                bEnear.setForeground(Color.gray);
                bEfar.setForeground(Color.gray);
                bEdif.setForeground(Color.gray);
                bErad.setForeground(Color.gray);
                
                int bleft = state.s20;
                int bmid = state.s200+state.s30;
                int bwide = state.s40;
                int bhigh = state.s15;
                int by1 = state.s8; int bdelta = state.s22;
                int by2 = by1 + bdelta;
                int by3 = by1 + 2*bdelta;
                int by4 = by1 + 3*bdelta;
                
                bHnear.setBounds(bleft,by1,bwide,bhigh);
                bHfar.setBounds(bleft,by2,bwide,bhigh);
                bHdif.setBounds(bleft,by3,bwide,bhigh);
                bEnear.setBounds(bmid,by1,bwide,bhigh);
                bEfar.setBounds(bmid,by2,bwide,bhigh);
                bEdif.setBounds(bmid,by3,bwide,bhigh);
                bErad.setBounds(bmid,by4,bwide,bhigh);
                
                add(bHnear); add(bHfar); add(bHdif);
                add(bEnear); add(bEfar); add(bEdif); add(bErad);
                
                pHnear.setBackground(Color.blue);
                add(pHnear);
                pHnear.setBounds(bleft-2,by1-2,bwide+4,bhigh+4);
                
                pHfar.setBackground(Color.gray);
                add(pHfar);
                pHfar.setBounds(bleft-2,by2-2,bwide+4,bhigh+4);
                
                pHdif.setBackground(Color.gray);
                add(pHdif);
                pHdif.setBounds(bleft-2,by3-2,bwide+4,bhigh+4);
                
                pEnear.setBackground(Color.gray);
                add(pEnear);
                pEnear.setBounds(bmid-2,by1-2,bwide+4,bhigh+4);
                
                pEfar.setBackground(Color.gray);
                add(pEfar);
                pEfar.setBounds(bmid-2,by2-2,bwide+4,bhigh+4);
                
                pEdif.setBackground(Color.gray);
                add(pEdif);
                pEdif.setBounds(bmid-2,by3-2,bwide+4,bhigh+4);
                
                pErad.setBackground(Color.gray);
                add(pErad);
                pErad.setBounds(bmid-2,by4-2,bwide+4,bhigh+4);
                
                information = new Button("ABOUT");
                information.setForeground(Color.blue);
                information.setBackground(Color.white);
                
                //add(information);
                information.setBounds(state.s500+state.s30,state.s5,state.s70,state.s23);
                
                //Panel ps7 = new Panel();
                ps7.setBackground(Color.lightGray);
                add(ps7);
                ps7.setBounds(state.s500+state.s29,state.s4,state.s72,state.s25);
	    
                //Panel ps8 = new Panel();
                ps8.setBackground(Color.black);
                add(ps8);
                ps8.setBounds(state.s500+state.s28,state.s3,state.s74,state.s27);
                
                //f1.addItemListener(this);
                //f2.addItemListener(this);
                
                bHnear.addActionListener(this);
                bHfar.addActionListener(this);
                bHdif.addActionListener(this);
                bEnear.addActionListener(this);
                bEfar.addActionListener(this);
                bEdif.addActionListener(this);
                bErad.addActionListener(this);
                
                //this.addMouseListener(this);
	}
        
    @Override
	public void paint(Graphics g){
	    Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            g.clearRect(0,0,getSize().width-1,getSize().height-1);
	
		//Draw the background	
		g.setColor(Color.black);
		g.drawLine(0,getSize().height-1,getSize().width-1,getSize().height-1);
		g.drawLine(getSize().width-1,0,getSize().width-1,getSize().height-1);
		//g.setColor(Color.white);
		
		g.drawLine(0,0,getSize().width-1,0);
		g.drawLine(0,0,0,getSize().height-1);
                
                //g.setColor(Color.blue.darker());
                //MaestroG.stringBold("Magnetic Field","","",g,state.font12,state.s80,state.s20);
                //g.setColor(Color.red.darker()); 
                //MaestroG.stringBold("Electric Field","","",g,state.font12,state.s200+state.s80,state.s20);
                
                
                int xshift = state.s70;
                int xplus = state.s200+state.s10;
                
                g.setColor(Color.blue.darker());
                    MaestroG.subsubsupItalic("H","\u03c6","","","  [exact solution]","","",g,state.font12,xshift,state.s20);
                    MaestroG.subsubsupItalic("H","\u03c6FF","","","  [far-field]","","",g,state.font12,xshift,state.s42);
                    MaestroG.subsubsupItalic("H","\u03c6"," \u2212 H","\u03c6FF","  [error]","","",g,state.font12,xshift,state.s64);   
                
                g.setColor(Color.red.darker());
                    MaestroG.subsubsupItalic("E","\u03b8","","","  [exact solution]","","",g,state.font12,xshift+xplus,state.s20);
                    MaestroG.subsubsupItalic("E","\u03b8FF","","","  [far-field]","","",g,state.font12,xshift+xplus,state.s42);
                    MaestroG.subsubsupItalic("E","\u03b8"," \u2212 E","\u03b8FF","  [error]","","",g,state.font12,xshift+xplus,state.s64);
                    MaestroG.subsubsupItalic("E","R","","","  [exact solution]","","",g,state.font12,xshift+xplus,state.s86);
                    
                int down = state.s6;
                /*
                if(IsMagnetic){
                    g.setColor(Color.black);
                    
                    // tab for H
                    g.drawLine(0,state.s20+down,state.s40,state.s20+down);
                    g.drawLine(state.s40,state.s20+down,state.s40,state.s8);
                    g.drawLine(state.s40,state.s8,state.s45,state.s3);
                    g.drawLine(state.s45,state.s3,state.s195,state.s3);
                    g.drawLine(state.s195,state.s3,state.s200,state.s8);
                    g.drawLine(state.s200,state.s8,state.s200,state.s20+down);
                    g.drawLine(state.s200,state.s20+down,state.s400+state.s70,state.s20+down);
                    
                    // tab for E
                    g.drawLine(state.s200+state.s40,state.s20+down,state.s200+state.s40,state.s8);
                    g.drawLine(state.s200+state.s40,state.s8,state.s200+state.s45,state.s3);
                    g.drawLine(state.s200+state.s45,state.s3,state.s300+state.s95,state.s3);
                    g.drawLine(state.s300+state.s95,state.s3,state.s400,state.s8);
                    g.drawLine(state.s400,state.s8,state.s400,state.s20+down);
                }
                else{
                    // tab for E
                    g.setColor(Color.black);
                    g.drawLine(0,state.s20+down,state.s200+state.s40,state.s20+down);
                    g.drawLine(state.s200+state.s40,state.s20+down,state.s200+state.s40,state.s8);
                    g.drawLine(state.s200+state.s40,state.s8,state.s200+state.s45,state.s3);
                    g.drawLine(state.s200+state.s45,state.s3,state.s300+state.s95,state.s3);
                    g.drawLine(state.s300+state.s95,state.s3,state.s400,state.s8);
                    g.drawLine(state.s400,state.s8,state.s400,state.s20+down);
                    g.drawLine(state.s400,state.s20+down,state.s400+state.s70,state.s20+down);
                    
                    //tab for H
                    g.drawLine(state.s40,state.s20+down,state.s40,state.s8);
                    g.drawLine(state.s40,state.s8,state.s45,state.s3);
                    g.drawLine(state.s45,state.s3,state.s195,state.s3);
                    g.drawLine(state.s195,state.s3,state.s200,state.s8);
                    g.drawLine(state.s200,state.s8,state.s200,state.s20+down);
                }
                */
                
                int x_one = state.s45;
                int x_two = state.s200 + state.s70;
                int y_one = state.s55;
                int y_two = state.s85;
                Color colore_radio;
                if(state.IsMagnetic){colore_radio = Color.blue.darker();}
                else{colore_radio = Color.red.darker();}
                /*
                // DRAW SCALABLE RADIO BUTTONS DONE BY HAND - BECAUSE OF WINDOWS 10 
                if(state.Select_near){
                    g.setColor(Color.white);
                    MaestroG.fillCircle(x_one,y_one, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.drawCircle(x_one,y_one, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.fillCircle(x_one,y_one, state.s5,g);

                    g.setColor(Color.white);
                    MaestroG.fillCircle(x_one,y_two, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.drawCircle(x_one,y_two, state.s13,g);
                    
                    g.setColor(Color.white);
                    MaestroG.fillCircle(x_two,y_one, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.drawCircle(x_two,y_one, state.s13,g);
                    
                    if(!state.IsMagnetic)
                    {
                        g.setColor(Color.white);
                        MaestroG.fillCircle(x_two,y_two, state.s13,g);
                        g.setColor(colore_radio);
                        MaestroG.drawCircle(x_two,y_two, state.s13,g);
                    }
                }
                if(state.Select_far){
                    g.setColor(Color.white);
                    MaestroG.fillCircle(x_one,y_one, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.drawCircle(x_one,y_one, state.s13,g);
                    
                    g.setColor(Color.white);
                    MaestroG.fillCircle(x_one,y_two, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.drawCircle(x_one,y_two, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.fillCircle(x_one,y_two, state.s5,g);
                    
                    g.setColor(Color.white);
                    MaestroG.fillCircle(x_two,y_one, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.drawCircle(x_two,y_one, state.s13,g);
                    
                    if(!state.IsMagnetic)
                    {
                        g.setColor(Color.white);
                        MaestroG.fillCircle(x_two,y_two, state.s13,g);
                        g.setColor(colore_radio);
                        MaestroG.drawCircle(x_two,y_two, state.s13,g);
                    }
                }
                if(state.Select_dif){
                    g.setColor(Color.white);
                    MaestroG.fillCircle(x_one,y_one, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.drawCircle(x_one,y_one, state.s13,g);
                    
                    g.setColor(Color.white);
                    MaestroG.fillCircle(x_one,y_two, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.drawCircle(x_one,y_two, state.s13,g);
                    
                    g.setColor(Color.white);
                    MaestroG.fillCircle(x_two,y_one, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.drawCircle(x_two,y_one, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.fillCircle(x_two,y_one, state.s5,g);
                    
                    if(!state.IsMagnetic)
                    {
                        g.setColor(Color.white);
                        MaestroG.fillCircle(x_two,y_two, state.s13,g);
                        g.setColor(colore_radio);
                        MaestroG.drawCircle(x_two,y_two, state.s13,g);
                    }
                }
                if(state.Select_r){
                    g.setColor(Color.white);
                    MaestroG.fillCircle(x_one,y_one, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.drawCircle(x_one,y_one, state.s13,g);
                    
                    g.setColor(Color.white);
                    MaestroG.fillCircle(x_one,y_two, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.drawCircle(x_one,y_two, state.s13,g);
                    
                    g.setColor(Color.white);
                    MaestroG.fillCircle(x_two,y_one, state.s13,g);
                    g.setColor(colore_radio);
                    MaestroG.drawCircle(x_two,y_one, state.s13,g);
                    
                    if(!state.IsMagnetic)
                    {
                        g.setColor(Color.white);
                        MaestroG.fillCircle(x_two,y_two, state.s13,g);
                        g.setColor(colore_radio);
                        MaestroG.drawCircle(x_two,y_two, state.s13,g);
                        g.setColor(colore_radio);
                        MaestroG.fillCircle(x_two,y_two, state.s5,g);
                    }
                }
                */
        }
        
	public synchronized void setDeltaLambda(double delta_lambda){
            this.delta_lambda = delta_lambda;
        }
        
        public void actionPerformed(ActionEvent evt){
            if(evt.getSource() == bHnear){
                pHnear.setBackground(Color.blue);
                pHfar.setBackground(Color.gray);
                pHdif.setBackground(Color.gray);
                pEnear.setBackground(Color.gray);
                pEfar.setBackground(Color.gray);
                pEdif.setBackground(Color.gray);
                pErad.setBackground(Color.gray);
                
                bHnear.setForeground(Color.blue);
                bHfar.setForeground(Color.gray);
                bHdif.setForeground(Color.gray);
                bEnear.setForeground(Color.gray);
                bEfar.setForeground(Color.gray);
                bEdif.setForeground(Color.gray);
                bErad.setForeground(Color.gray);
                
                if(state.IsMac){
                    bHnear.setLabel("\u2714");
                }
                else{
                    bHnear.setLabel("\u2713");
                }
                
                bHfar.setLabel("");
                bHdif.setLabel("");
                bEnear.setLabel("");
                bEfar.setLabel("");
                bEdif.setLabel("");
                bErad.setLabel("");
                
                repaint();
            }
            else if(evt.getSource() == bHfar){
                pHnear.setBackground(Color.gray);
                pHfar.setBackground(Color.blue);
                pHdif.setBackground(Color.gray);
                pEnear.setBackground(Color.gray);
                pEfar.setBackground(Color.gray);
                pEdif.setBackground(Color.gray);
                pErad.setBackground(Color.gray);
                
                bHnear.setForeground(Color.gray);
                bHfar.setForeground(Color.blue);
                bHdif.setForeground(Color.gray);
                bEnear.setForeground(Color.gray);
                bEfar.setForeground(Color.gray);
                bEdif.setForeground(Color.gray);
                bErad.setForeground(Color.gray);
                
                bHnear.setLabel("");
                if(state.IsMac){
                    bHfar.setLabel("\u2714");
                }
                else{
                    bHfar.setLabel("\u2713");
                }
                bHdif.setLabel("");
                bEnear.setLabel("");
                bEfar.setLabel("");
                bEdif.setLabel("");
                bErad.setLabel("");
                
                repaint();
            }
            else if(evt.getSource() == bHdif){
                pHnear.setBackground(Color.gray);
                pHfar.setBackground(Color.gray);
                pHdif.setBackground(Color.blue);
                pEnear.setBackground(Color.gray);
                pEfar.setBackground(Color.gray);
                pEdif.setBackground(Color.gray);
                pErad.setBackground(Color.gray);
                
                bHnear.setForeground(Color.gray);
                bHfar.setForeground(Color.gray);
                bHdif.setForeground(Color.blue);
                bEnear.setForeground(Color.gray);
                bEfar.setForeground(Color.gray);
                bEdif.setForeground(Color.gray);
                bErad.setForeground(Color.gray);
                
                bHnear.setLabel("");
                bHfar.setLabel("");
                if(state.IsMac){
                    bHdif.setLabel("\u2714");
                }
                else{
                    bHdif.setLabel("\u2713");
                }
                bEnear.setLabel("");
                bEfar.setLabel("");
                bEdif.setLabel("");
                bErad.setLabel("");
                
                repaint();
            }
            if(evt.getSource() == bEnear){
                pHnear.setBackground(Color.gray);
                pHfar.setBackground(Color.gray);
                pHdif.setBackground(Color.gray);
                pEnear.setBackground(Color.red);
                pEfar.setBackground(Color.gray);
                pEdif.setBackground(Color.gray);
                pErad.setBackground(Color.gray);
                
                bHnear.setForeground(Color.gray);
                bHfar.setForeground(Color.gray);
                bHdif.setForeground(Color.gray);
                bEnear.setForeground(Color.red);
                bEfar.setForeground(Color.gray);
                bEdif.setForeground(Color.gray);
                bErad.setForeground(Color.gray);
                
                bHnear.setLabel("");
                bHfar.setLabel("");
                bHdif.setLabel("");
                if(state.IsMac){
                    bEnear.setLabel("\u2714");
                }
                else{
                    bEnear.setLabel("\u2713");
                }
                bEfar.setLabel("");
                bEdif.setLabel("");
                bErad.setLabel("");
                
                repaint();
            }
            else if(evt.getSource() == bEfar){
                pHnear.setBackground(Color.gray);
                pHfar.setBackground(Color.gray);
                pHdif.setBackground(Color.gray);
                pEnear.setBackground(Color.gray);
                pEfar.setBackground(Color.red);
                pEdif.setBackground(Color.gray);
                pErad.setBackground(Color.gray);
                
                bHnear.setForeground(Color.gray);
                bHfar.setForeground(Color.gray);
                bHdif.setForeground(Color.gray);
                bEnear.setForeground(Color.gray);
                bEfar.setForeground(Color.red);
                bEdif.setForeground(Color.gray);
                bErad.setForeground(Color.gray);
                
                bHnear.setLabel("");
                bHfar.setLabel("");
                bHdif.setLabel("");
                bEnear.setLabel("");
                if(state.IsMac){
                    bEfar.setLabel("\u2714");
                }
                else{
                    bEfar.setLabel("\u2713");
                }
                bEdif.setLabel("");
                bErad.setLabel("");
                
                repaint();
            }
            else if(evt.getSource() == bEdif){
                pHnear.setBackground(Color.gray);
                pHfar.setBackground(Color.gray);
                pHdif.setBackground(Color.gray);
                pEnear.setBackground(Color.gray);
                pEfar.setBackground(Color.gray);
                pEdif.setBackground(Color.red);
                pErad.setBackground(Color.gray);
                
                bHnear.setForeground(Color.gray);
                bHfar.setForeground(Color.gray);
                bHdif.setForeground(Color.gray);
                bEnear.setForeground(Color.gray);
                bEfar.setForeground(Color.gray);
                bEdif.setForeground(Color.red);
                bErad.setForeground(Color.gray);
                
                bHnear.setLabel("");
                bHfar.setLabel("");
                bHdif.setLabel("");
                bEnear.setLabel("");
                bEfar.setLabel("");
                if(state.IsMac){
                    bEdif.setLabel("\u2714");
                }
                else{
                    bEdif.setLabel("\u2713");
                }
                bErad.setLabel("");
                
                repaint();
            }
            else if(evt.getSource() == bErad){
                pHnear.setBackground(Color.gray);
                pHfar.setBackground(Color.gray);
                pHdif.setBackground(Color.gray);
                pEnear.setBackground(Color.gray);
                pEfar.setBackground(Color.gray);
                pEdif.setBackground(Color.gray);
                pErad.setBackground(Color.red);
                
                bHnear.setForeground(Color.gray);
                bHfar.setForeground(Color.gray);
                bHdif.setForeground(Color.gray);
                bEnear.setForeground(Color.gray);
                bEfar.setForeground(Color.gray);
                bEdif.setForeground(Color.gray);
                bErad.setForeground(Color.red);
                
                bHnear.setLabel("");
                bHfar.setLabel("");
                bHdif.setLabel("");
                bEnear.setLabel("");
                bEfar.setLabel("");
                bEdif.setLabel("");
                if(state.IsMac){
                    bErad.setLabel("\u2714");
                }
                else{
                    bErad.setLabel("\u2713");
                }
                
                repaint();
            }
        }

    /*
        public void itemStateChanged(ItemEvent evt){
	    ItemSelectable ie = evt.getItemSelectable();
	    
            if(evt.getSource()== f1){
                IsMagnetic = true;
                c3.setVisible(false);
                repaint();
            }
            
            if(evt.getSource()== f2){
                IsMagnetic = false;
                c3.setVisible(true);
                repaint();
            }
        }
    */
        
        public void mouseClicked(MouseEvent evt){
        x = evt.getX();
	y = evt.getY();
            
            if((x >= state.s20 && x<= state.s200) && (y >= 0 && y<= state.s30)){
                IsMagnetic = true;
                f1 = true;
                f2 = false;
                //c3.setVisible(false);
                //state.ignition();
                repaint();
            }
            else if((x >= (state.s200+state.s30) && x<= (state.s400)) && (y >= 0 && y<= state.s30)){
                IsMagnetic = false;
                f2 = true;
                f1 = false;
                //c3.setVisible(true);
                //state.ignition();
                repaint();
            }
            
        }
        
    private void myEventHandler(MouseEvent evt){
        
    }
    
    public void mouseEntered(MouseEvent evt){ }
    public void mouseExited(MouseEvent evt) { }
    public void mousePressed(MouseEvent evt) {myEventHandler(evt);}
    public void mouseReleased(MouseEvent evt) { }
} // ChoicePanel.java
