View Javadoc

1   /*
2    *   Magic-Project is a turn based strategy simulator
3    *   Copyright (C) 2003-2007 Fabrice Daugan
4    *
5    *   This program is free software; you can redistribute it and/or modify it 
6    * under the terms of the GNU General Public License as published by the Free 
7    * Software Foundation; either version 2 of the License, or (at your option) any
8    * later version.
9    *
10   *   This program is distributed in the hope that it will be useful, but WITHOUT 
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
13   * details.
14   *
15   *   You should have received a copy of the GNU General Public License along  
16   * with this program; if not, write to the Free Software Foundation, Inc., 
17   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  package net.sf.magicproject.tools;
20  
21  import java.awt.event.ActionEvent;
22  import java.awt.event.ActionListener;
23  
24  import javax.swing.JComponent;
25  
26  /***
27   * Bring to front manager
28   * 
29   * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
30   * @since 0.84
31   */
32  public class BringToFrontListener implements ActionListener {
33  
34  	public void actionPerformed(ActionEvent e) {
35  		// TODO Bring To Front Listener refresher
36  	}
37  
38  	/***
39  	 * Set the bring to front component. This restore the previous bring to front
40  	 * component state, then bring this component to front. Bringing to front
41  	 * simply repaint a component.
42  	 * 
43  	 * @param component
44  	 */
45  	public void setBringToFrontComponent(JComponent component) {
46  		// if (!isBringToFront(component)) {
47  		if (this.component != null) {
48  			this.component.getParent().repaint();
49  		}
50  		this.component = component;
51  		this.component.getParent().repaint();
52  		// }
53  	}
54  
55  	/***
56  	 * Return the current bring to front component. If none, retur null.
57  	 * 
58  	 * @return the current bring to front component. If none, retur null.
59  	 */
60  	public JComponent getBringToFrontComponent() {
61  		return component;
62  	}
63  
64  	/***
65  	 * Indicates the specified component is the bring to front one.
66  	 * 
67  	 * @param component
68  	 *          the tested component.
69  	 * @return true if the specified component is the bring to front one.
70  	 */
71  	public boolean isBringToFront(JComponent component) {
72  		return this.component == component;
73  	}
74  
75  	/***
76  	 * The last bring to front component.
77  	 */
78  	private JComponent component;
79  
80  }