GUI printing Server's Peer Group Leader list
git-svn-id: svn://anubis/gvsu@59 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
0e63ffa48b
commit
137a5f031b
@ -37,6 +37,7 @@ public class KaZaGUI extends JFrame
|
||||
private JButton m_serverStartButton;
|
||||
private JTextField m_serverPeerAddressField;
|
||||
private JButton m_serverPeerConnectButton;
|
||||
private JLabel m_serverPeerGroupLeadersLabel;
|
||||
|
||||
public KaZaGUI()
|
||||
{
|
||||
@ -144,6 +145,19 @@ public class KaZaGUI extends JFrame
|
||||
first = false;
|
||||
}
|
||||
m_serverClientsLabel.setText(caption);
|
||||
|
||||
Object[] peers = m_server.getPeerGroupLeaderList();
|
||||
caption = "Peer Group Leaders (" + peers.length + "): ";
|
||||
first = true;
|
||||
for (Object o : peers)
|
||||
{
|
||||
String s = (String) o;
|
||||
if (!first)
|
||||
caption += ", ";
|
||||
caption += s;
|
||||
first = false;
|
||||
}
|
||||
m_serverPeerGroupLeadersLabel.setText(caption);
|
||||
}
|
||||
|
||||
synchronized (m_activeDownloads)
|
||||
@ -168,6 +182,7 @@ public class KaZaGUI extends JFrame
|
||||
{
|
||||
m_server.connectToPeerGroupLeader(
|
||||
m_serverPeerAddressField.getText());
|
||||
m_serverPeerAddressField.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -353,9 +368,11 @@ public class KaZaGUI extends JFrame
|
||||
m_serverPeerAddressField = new JTextField();
|
||||
m_serverPeerConnectButton = new JButton("Connect");
|
||||
m_serverPeerConnectButton.addActionListener(m_handler);
|
||||
m_serverPeerGroupLeadersLabel = new JLabel();
|
||||
|
||||
JPanel serverPanel = new JPanel();
|
||||
serverPanel.setLayout(new BoxLayout(serverPanel, BoxLayout.Y_AXIS));
|
||||
|
||||
JPanel p = new JPanel();
|
||||
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
|
||||
p.add(m_serverClientsLabel);
|
||||
@ -363,6 +380,14 @@ public class KaZaGUI extends JFrame
|
||||
new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)));
|
||||
serverPanel.add(p);
|
||||
|
||||
p = new JPanel();
|
||||
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
|
||||
p.add(m_serverPeerGroupLeadersLabel);
|
||||
p.add(new Box.Filler(new Dimension(0, 0), new Dimension(Short.MAX_VALUE, 0),
|
||||
new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)));
|
||||
serverPanel.add(p);
|
||||
|
||||
|
||||
p = new JPanel();
|
||||
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
|
||||
p.add(new JLabel("Peer Group Leader to link to: "));
|
||||
|
@ -71,6 +71,19 @@ public class KaZaServer implements Runnable
|
||||
return s.toArray();
|
||||
}
|
||||
|
||||
public Object[] getPeerGroupLeaderList()
|
||||
{
|
||||
Vector<String> peers = new Vector<String>();
|
||||
synchronized (m_peerGroupLeaders)
|
||||
{
|
||||
for (Socket s : m_peerGroupLeaders)
|
||||
{
|
||||
peers.add(s.getInetAddress().getHostAddress());
|
||||
}
|
||||
}
|
||||
return peers.toArray();
|
||||
}
|
||||
|
||||
private class ClientInfo
|
||||
{
|
||||
String userName = "Anonymous";
|
||||
|
Loading…
x
Reference in New Issue
Block a user