/*
* Copyright (C) 2011-2014 GeoForge Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.geoforge.guillc.panel;
import java.awt.event.ActionListener;
import java.util.Enumeration;
import javax.swing.AbstractButton;
import javax.swing.BoxLayout;
import javax.swing.JRadioButton;
import org.geoforge.guillc.buttongroup.GfrBgp;
/**
*
* @author Amadeus.Sowerby
*
* email: Amadeus.Sowerby_AT_gmail.com ... please remove "_AT_" from the above
* string to get the right email address
*
*/
public class GfrPnlGrpRbnGroup extends GfrPnlGrpAbs
{
private int _intOrientation_ = BoxLayout.Y_AXIS;
protected GfrPnl _pnl_ = null;
protected GfrBgp _grpBtn = null;
public GfrPnlGrpRbnGroup(String strWhat)
{
super(
strWhat,
20);
//--
this._pnl_ = new GfrPnl();
}
@Override
public boolean init()
{
if (!super.init())
return false;
if (!this._pnl_.init())
return false;
if (!this._grpBtn.init())
return false;
this._pnl_.setLayout(new BoxLayout(this._pnl_, _intOrientation_));
Enumeration<AbstractButton> enu = _grpBtn.getElements();
while (enu.hasMoreElements())
{
JRadioButton btn = (JRadioButton) enu.nextElement();
this._pnl_.add(btn);
btn.addActionListener((ActionListener) this);
}
super.setMandatoryIcon(false);
super._pnlContent.add(this._pnl_);
return true;
}
@Override
public void destroy()
{
super.destroy();
if (this._pnl_ != null)
{
this._pnl_.destroy();
this._pnl_ = null;
}
if (this._grpBtn != null)
{
this._grpBtn.destroy();
this._grpBtn = null;
}
}
public void setOrientation(int orientation)
{
this._intOrientation_ = orientation;
this._pnl_.setLayout(new BoxLayout(this._pnl_, _intOrientation_));
}
public void setBgp(GfrBgp bgp)
{
this._grpBtn = bgp;
}
}