/*
This file is part of the software framework JStatCom,
a library for building applications for data based analysis.
Copyright (C) 2000-2005 Markus Kraetzig
This library 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 2.1 of the
License, or (at your option) any later version.
This library 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 library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
*/
package com.jstatcom.equation;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.ContainerAdapter;
import java.awt.event.ContainerEvent;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
/**
* Panel to be used as the container for all EqTerm components. It manages
* the setting/unsetting of the leading signs and keeps track of the correct
* reference point. It uses the EqLayout to display potentially
* large equations.
*
* @author Alexander Benkwitz, Markus Kraetzig
*/
public final class EqPanel extends JPanel {
/**
* Constructor.
*/
public EqPanel() {
super(new EqLayout());
setBorder(new EmptyBorder(0, 5, 0, 5));
addContainerListener(new ContainerAdapter() {
public void componentAdded(ContainerEvent evt) {
if (evt.getChild() instanceof EqTermLHS) {
if (getLayout() instanceof EqLayout)
((EqLayout) getLayout()).numberLHS++;
}
}
});
}
/**
* Delegates setEnabled to all childs of this container.
*
* @param c java.awt.Component[]
* @param enabled boolean
*/
private void enableComponentsAndChilds(Component[] c, boolean enabled) {
if (c != null) {
for (int i = 0; i < c.length; i++) {
c[i].setEnabled(enabled);
if (c[i] instanceof Container) {
enableComponentsAndChilds(
((Container) c[i]).getComponents(),
enabled);
}
}
}
}
/**
* Overwrites supermethod to delegate the call to
* all childs.
*
* @param enabled true if enabled
*/
public void setEnabled(boolean enabled) {
enableComponentsAndChilds(getComponents(), enabled);
super.setEnabled(enabled);
}
}
Ads help maintain this website.