/**
*#########################################################################
*
* A component of the Gatherer application, part of the Greenstone digital
* library suite from the New Zealand Digital Library Project at the
* University of Waikato, New Zealand.
*
*
*
* Author: John Thompson, Greenstone Digital Library, University of Waikato
*
*
*
* Copyright (C) 1999 New Zealand Digital Library Project
*
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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 General Public License for more details.
*
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*########################################################################
*/
package org.greenstone.gatherer.gems;
import java.awt.Color;
import javax.swing.JTree;
import javax.swing.tree.*;
import java.awt.event.*;
/** An extension of a JTree that allows for the background, foreground and selection colors to be set in single actions. */
public class SmarterTree extends JTree implements ActionListener{
public SmarterTree() {
super();
}
public SmarterTree(TreeModel model) {
super(model);
}
public boolean isSelectionEmpty() {
return super.isSelectionEmpty();
}
public void setBackground(Color color) {
super.setBackground(color);
if(cellRenderer != null) {
((DefaultTreeCellRenderer)cellRenderer).setBackgroundNonSelectionColor(color);
}
}
public void setForeground(Color color) {
super.setForeground(color);
if(cellRenderer != null) {
((DefaultTreeCellRenderer)cellRenderer).setTextNonSelectionColor(color);
}
}
public void setSelectionColor(Color color) {
((DefaultTreeCellRenderer)cellRenderer).setBackgroundSelectionColor(color);
}
public void setSelectedTextColor(Color color) {
((DefaultTreeCellRenderer)cellRenderer).setTextNonSelectionColor(color);
}
public void actionPerformed(ActionEvent e) {
System.out.println("Action!");
}
}