View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  package org.xnap.plugin.overnet.gui;
20  
21  import javax.swing.SwingUtilities;
22  
23  import org.xnap.event.StateEvent;
24  import org.xnap.event.StateListener;
25  import org.xnap.gui.StatusPanel;
26  import org.xnap.plugin.overnet.OvernetPlugin;
27  import org.xnap.plugin.overnet.net.OvernetCore;
28  
29  
30  /***
31   * Overnet's status panel displaying the state of its connection to the core.
32   */
33  public class OvernetStatusPanel extends StatusPanel implements StateListener
34  {
35  	public OvernetStatusPanel()
36  	{
37  		setName(OvernetPlugin.getInstance().getInfo().getName());
38  		setIcon(OvernetPlugin.ICON_16);
39  		setText(OvernetPlugin.getInstance().getCore().getState().getDescription());
40  	}
41  	
42      /*
43       * @see org.xnap.event.StateListener#stateChanged(org.xnap.event.StateEvent)
44       */
45      public void stateChanged(StateEvent event)
46      {
47      	OvernetCore core = (OvernetCore)event.getSource();
48      	final String status = core.getState().getDescription();	
49      	Runnable r = new Runnable()
50      	{
51      		public void run()
52      		{
53      			setText(status);
54      		}
55      	};
56      	SwingUtilities.invokeLater(r);
57      }
58  }