|
10 | 10 | import edu.wpi.first.smartdashboard.xml.SmartDashboardXMLReader;
|
11 | 11 | import edu.wpi.first.smartdashboard.xml.SmartDashboardXMLWriter;
|
12 | 12 | import edu.wpi.first.smartdashboard.xml.XMLWidget;
|
| 13 | +import edu.wpi.first.wpilibj.networktables.NetworkTable; |
| 14 | +import edu.wpi.first.wpilibj.networktables.NetworkTablesJNI; |
13 | 15 | import java.awt.BorderLayout;
|
14 | 16 | import java.awt.CardLayout;
|
15 | 17 | import java.awt.Dimension;
|
|
38 | 40 | */
|
39 | 41 | public class DashboardFrame extends JFrame {
|
40 | 42 |
|
| 43 | + private static final String TITLE = "SmartDashboard | "; |
| 44 | + |
41 | 45 | /*
|
42 | 46 | * If the menu bar is set to "hidden," then this defines what portion of the
|
43 | 47 | * top screen is reserved for revealing the menu bar when the mouse moves
|
@@ -96,7 +100,18 @@ public static DashboardFrame getInstance() {
|
96 | 100 | * @param competition whether or not to display as though it were on the netbook
|
97 | 101 | */
|
98 | 102 | public DashboardFrame(boolean competition) {
|
99 |
| - super("SmartDashboard - "); |
| 103 | + NetworkTablesJNI.ConnectionListenerFunction clf = (uid, connected, conn) -> { |
| 104 | + if (NetworkTable.getTable("").isServer()) { |
| 105 | + setTitle(TITLE + "Number of Clients: " + NetworkTablesJNI.getConnections().length); |
| 106 | + } else if (connected && conn != null) { |
| 107 | + setTitle(TITLE + "Connected: " + conn.remote_ip); |
| 108 | + } else { |
| 109 | + setTitle(TITLE + "Disconnected"); |
| 110 | + } |
| 111 | + }; |
| 112 | + clf.apply(0, false, null); |
| 113 | + |
| 114 | + NetworkTablesJNI.addConnectionListener(clf, true); |
100 | 115 |
|
101 | 116 | setLayout(new BorderLayout());
|
102 | 117 |
|
|
0 commit comments