{
boolean wasExpanded = treeCellUI.isExpanded();
if (wasExpanded == expand)
return; // No cambia el estado
TreeExpansionEvent event = null;
TreePath treePath = treeCellUI.getTreePath();
if (hasTreeWillExpandListeners())
{
event = new TreeExpansionEvent(this, treePath);
TreeWillExpandListener[] listeners = getTreeWillExpandListeners();
try
{
for (int i = 0; i < listeners.length; i++)
{
if (expand)
listeners[i].treeWillExpand(event);
else
listeners[i].treeWillCollapse(event);
}
}
catch (ExpandVetoException ex)
{
// Cancelada la expansi�n/cancelaci�n
return;
}
}
treeCellUI.expand(expand);
// Ha cambiado el estado, notificamos
if (hasTreeExpansionListeners())
{
if (event == null) // Como es un objeto de s�lo lectura si ya se cre� antes lo reutilizamos
event = new TreeExpansionEvent(this, treePath);
TreeExpansionListener[] listeners = getTreeExpansionListeners();
for (int i = 0; i < listeners.length; i++)
{
if (expand)