2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
6
* This program is distributed in the hope that it will be useful,
7
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
* GNU General Public License for more details.
10
* You should have received a copy of the GNU General Public License
11
* along with this program; if not, write to the Free Software
12
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
package games.strategy.engine.lobby.server.ui;
17
import java.awt.GridLayout;
18
import java.util.Date;
20
import games.strategy.net.*;
21
import games.strategy.triplea.ui.MemoryLabel;
25
public class LobbyAdminStatPanel extends JPanel
28
private JLabel m_upSince;
29
private JLabel m_maxPlayersLabel;
30
private JLabel m_totalLoginsLabel;
31
private JLabel m_currentLoginsLabel;
32
private int m_maxPlayers;
33
private int m_totalLogins;
34
private int m_currentLogins;
35
private final IMessenger m_messenger;
37
public LobbyAdminStatPanel(IMessenger messenger)
39
m_messenger = messenger;
43
setWidgetActivation();
46
private void createComponents()
48
m_currentLoginsLabel = new JLabel("Current Players: -----");
49
m_maxPlayersLabel = new JLabel("Max Concurrent Players : ----");
50
m_totalLoginsLabel = new JLabel("Total Logins : ------");
51
m_upSince = new JLabel("Up since " + new Date());
55
private void layoutComponents()
57
setLayout(new GridLayout(5,1));
58
add(m_currentLoginsLabel);
59
add(m_totalLoginsLabel);
60
add(m_maxPlayersLabel);
62
add(new MemoryLabel());
65
private void setupListeners()
67
((IServerMessenger) m_messenger).addConnectionChangeListener(new IConnectionChangeListener()
70
public void connectionRemoved(INode to)
72
SwingUtilities.invokeLater(new Runnable()
78
m_currentLoginsLabel.setText("Current Players: " + m_currentLogins);
85
public void connectionAdded(INode to)
87
SwingUtilities.invokeLater(new Runnable()
93
m_currentLoginsLabel.setText("Current Players: " + m_currentLogins);
95
if(m_currentLogins > m_maxPlayers)
97
m_maxPlayers = m_currentLogins;
98
m_maxPlayersLabel.setText("Max Concurrent Players : " + m_maxPlayers);
101
m_totalLoginsLabel.setText("Total Logins : " + m_totalLogins);
114
private void setWidgetActivation()