Files
Projet-UDP/ChatApp/app/src/main/java/client/UsernameSingleton.java
2025-03-12 23:16:39 +01:00

32 lines
757 B
Java

package client;
/**
* This class aims to make the username available to all controllers. (Recommended by JavaFX, because otherwise, FXMLLoader bugs and doesn't switch scenes properly.)
*/
public class UsernameSingleton {
private static UsernameSingleton instance;
private String username;
private UsernameSingleton() {
}
/**
* Get the instance of the singleton.
* @return the instance
*/
public static UsernameSingleton getInstance() {
if (instance == null) {
instance = new UsernameSingleton();
}
return instance;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}