Answer the question
In order to leave comments, you need to log in
JavaFX how to keep inner elements across scene transitions?
I am writing a chat application in javafx and faced the task of preserving the internal elements of the container during transitions between scenes. In my case it is as follows : after creating a chat room (Class Room)
public class Room {
public int id;
public String roomName;
public static int lastId = 0;
public Room(String roomName) {
this.id = lastId;
this.setRoomName(roomName);
lastId++;
}
public Room(int id, String roomName) {
this.id = id;
this.setRoomName(roomName);
lastId++;
}
public Room() {
this.id = lastId;
this.setRoomName(roomName);
lastId++;
}
@Override
public String toString() {
return this.getRoomName();
}
public int getId() {
return id;
}
public String getRoomName() {
return roomName;
}
public void setRoomName(String roomName) {
this.roomName = roomName;
}
}
@FXML
public void createRoom() {
Room room = new Room("Room #");
room.setRoomName(room.roomName + room.getId());
rooms.getItems().add(room);
Connect con = new Connect();
con.createRoom(room.roomName);
}
@FXML
public ListView<Room> rooms = new ListView<Room>();
after going to the chat scene (by clicking on a room from the list) Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question