Package test.comp.free

Source Code of test.comp.free.TestFreeCheckBox

/*
* TestSelectComboBoxListener.java
*
* Created on 26 de octubre de 2006, 16:59
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package test.comp.free;

import org.itsnat.core.html.ItsNatHTMLDocument;
import org.itsnat.comp.button.toggle.ItsNatFreeCheckBox;
import javax.swing.ButtonModel;
import javax.swing.JToggleButton.ToggleButtonModel;
import javax.swing.event.ChangeEvent;
import org.itsnat.comp.ItsNatComponentManager;
import org.w3c.dom.Document;
import org.w3c.dom.css.ElementCSSInlineStyle;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.html.HTMLElement;
import test.comp.*;

/**
*
* @author jmarranz
*/
public abstract class TestFreeCheckBox extends TestCheckBoxBase implements EventListener
{
    protected ElementCSSInlineStyle elemStyle;
    protected ItsNatFreeCheckBox button;

    /**
     * Creates a new instance of TestSelectComboBoxListener
     */
    public TestFreeCheckBox(ItsNatHTMLDocument itsNatDoc)
    {
        super(itsNatDoc);
    }

    public void init(String id)
    {
        Document doc = itsNatDoc.getDocument();
        HTMLElement elem = (HTMLElement)doc.getElementById(id);
        ItsNatComponentManager componentMgr = itsNatDoc.getItsNatComponentManager();
        this.button = (ItsNatFreeCheckBox)componentMgr.findItsNatComponent(elem);

        ToggleButtonModel dataModel = new ToggleButtonModel();
        button.setButtonModel(dataModel);

        button.addEventListener("click",this);

        dataModel.addChangeListener(this);

        this.elemStyle = (ElementCSSInlineStyle)elem;
    }

    public void handleEvent(Event evt)
    {
        outText("OK " + evt.getType() + " "); // Para que se vea
    }

    public void stateChanged(ChangeEvent e)
    {
        super.stateChanged(e);

        ButtonModel model = (ButtonModel)e.getSource();
        FreeToggleButtonUtil.updateDecoration(model,elemStyle);
    }
}
TOP

Related Classes of test.comp.free.TestFreeCheckBox

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.