final Tab tab = new Tab(xmppSession.getDomain());
tab.setContent(debugView);
tab.textProperty().bind(title);
connectionListenerMap.put(tab, connectionListener);
final AnimationTimer animationTimer = new AnimationTimer() {
@Override
public void handle(long now) {
if (outputStreamIncoming != null) {
String incoming = outputStreamIncoming.toString();
if (!incoming.isEmpty()) {
debugController.appendTextIncoming(incoming);
outputStreamIncoming.reset();
}
}
if (outputStreamOutgoing != null) {
String outgoing = outputStreamOutgoing.toString();
if (!outgoing.isEmpty()) {
debugController.appendTextOutgoing(outgoing);
outputStreamOutgoing.reset();
}
}
}
};
animationTimer.start();
tab.setOnClosed(new EventHandler<Event>() {
@Override
public void handle(Event event) {
xmppSession.removeSessionStatusListener(connectionListenerMap.remove(tab));
xmppSession.removePresenceListener(presenceListener);
animationTimer.stop();
}
});
tabPane.getTabs().add(tab);
stage.show();