Package org.flexdock.view

Source Code of org.flexdock.view.Button

/*
* Created on Mar 1, 2005
*/
package org.flexdock.view;

import javax.swing.Action;
import javax.swing.ButtonModel;
import javax.swing.JToggleButton;
import javax.swing.SwingUtilities;

import org.flexdock.plaf.PlafManager;
import org.flexdock.view.model.ViewButtonModel;

/**
* @author Christopher Butler
*/
public class Button extends JToggleButton {

    public static final String uiClassID = "Flexdock.titlebar.button";

    public Button(Action action) {
        setAction(action);
        setModel(new ViewButtonModel());
    }

    public void setModel(ButtonModel newModel) {
        ButtonModel oldModel = getModel();
        if(newModel!=null && oldModel!=null)
            newModel.setSelected(oldModel.isSelected());
        super.setModel(newModel);
    }

    public void updateUI() {
        setUI(PlafManager.getUI(this));
    }

    public String getUIClassID() {
        return uiClassID;
    }

    public View getView() {
        return (View)SwingUtilities.getAncestorOfClass(View.class, this);
    }

    public String getActionName() {
        Action action = getAction();
        if(action==null)
            return null;
        return (String)action.getValue(Action.NAME);
    }
}
TOP

Related Classes of org.flexdock.view.Button

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.