32 lines
757 B
Java
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;
|
|
}
|
|
}
|