01: /*
02: * Copyright (C) 2004 NNL Technology AB
03: * Visit www.infonode.net for information about InfoNode(R)
04: * products and how to contact NNL Technology AB.
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19: * MA 02111-1307, USA.
20: */
21:
22: // $Id: TitledTabHoverAction.java,v 1.12 2005/02/16 11:28:14 jesper Exp $
23: package net.infonode.tabbedpanel.hover;
24:
25: import net.infonode.gui.hover.HoverEvent;
26: import net.infonode.gui.hover.HoverListener;
27: import net.infonode.tabbedpanel.titledtab.TitledTab;
28: import net.infonode.tabbedpanel.titledtab.TitledTabProperties;
29:
30: /**
31: * <p>
32: * TitledTabHoverAction is an action that makes it easy to change properties for
33: * a hovered {@link TitledTab}. The action is meant to be set as a {@link HoverListener}
34: * in the {@link TitledTabProperties}.
35: * </p>
36: *
37: * <p>
38: * This hover action contains a TitledTabProperties object that will be added as
39: * super object to the hovered titled tab and then automatically removed when the
40: * titled tab is no longer hovered.
41: * </p>
42: *
43: * @author johan
44: * @version $Revision: 1.12 $
45: * @see TitledTab
46: * @see TitledTabProperties
47: * @since ITP 1.3.0
48: */
49: public class TitledTabHoverAction implements HoverListener {
50: private TitledTabProperties props;
51:
52: /**
53: * Creates a TitledTabHoverAction containing an empty TitledTabProperties
54: * object.
55: */
56: public TitledTabHoverAction() {
57: this (new TitledTabProperties());
58: }
59:
60: /**
61: * Creates a TitledTabHoverAction with the given TitledTabProperties
62: * object.
63: *
64: * @param props reference to a TitledTabProperties object
65: */
66: public TitledTabHoverAction(TitledTabProperties props) {
67: this .props = props;
68: }
69:
70: /**
71: * Gets the TitledTabProperties object for this action.
72: *
73: * @return reference to the TitledTabProperties
74: */
75: public TitledTabProperties getTitledTabProperties() {
76: return props;
77: }
78:
79: public void mouseEntered(HoverEvent event) {
80: ((TitledTab) event.getSource()).getProperties().addSuperObject(
81: props);
82: }
83:
84: public void mouseExited(HoverEvent event) {
85: ((TitledTab) event.getSource()).getProperties()
86: .removeSuperObject(props);
87: }
88: }
|