import java.awt.*;

public class FieldOn extends Panel{
    private static final Color bgcolor = Color.white;
    public Checkbox Ebox, Hbox;
    public Button b1;
    public int CurrentTime, TotalTime;
    private Image im;
    private Graphics buf;
    PlaneWave_State state;
    
    public FieldOn(PlaneWave_State state){
	super();
        setLayout(null);
        this.state = state;
        
	setBackground(bgcolor);
        b1 = new Button("Reset");
        b1.setBackground(Color.white);
	//add(b1);
	//b1.setBounds(5,25,50,18);
                
	Ebox = new Checkbox("",null,true);
        Hbox = new Checkbox("",null,false);
        add(Ebox);
	Ebox.setBackground(bgcolor);
        Ebox.setForeground(Color.red);
        
        add(Hbox);
	Hbox.setBackground(bgcolor);       
        Hbox.setForeground(Color.blue);
        
        Ebox.setBounds(state.s30,state.s2,state.s20,state.s20);
        Hbox.setBounds(state.s100,state.s2,state.s20,state.s20);
        //frequency = 1.0E9;
        CurrentTime = 0;
        TotalTime = 0;
    }
    
    public void paint(Graphics g){
	    if(im == null){
		im = createImage(getSize().width,getSize().height);
		buf = im.getGraphics();
		drawGraph(buf);
	    }
	    else{
		drawGraph(buf);
	    }
	    g.drawImage(im,0,0,null);
    }
	
	//Addition to reduce flicker new routine
    public void update(Graphics g){		// added to avoid clearing
	    paint(g);
    }
    
    public void drawGraph(Graphics g){
	g.setColor(bgcolor);	
	g.fillRect(0,0,getSize().width-1,getSize().height-1);  
        
        Graphics2D g2d = (Graphics2D)g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
        g.setColor(Color.red);
        //MaestroG.subscripterSansItalic3("E","x","( t )",g,state.font12,state.s50,state.s14);
        MaestroG.subscripterB("E","x","(t)",g,state.font13,state.s50,state.s14);
        g.setColor(Color.blue);
	//MaestroG.subscripterSansItalic3("H","y","( t )",g,state.font12,state.s120,state.s14);
        MaestroG.subscripterB("H","y","(t)",g,state.font13,state.s120,state.s14);
    }
}