I am success to change the pane in stack pane with .setVisible()
when the button is in the main scene, not in the stack pane.
But when I want to change my pane with clicking the button in one of the pane , I'll get the NullPointer error......
I tried to create the StackPane controller in every pane controller, and use the method .isPressed()
to controll the pane visible , so how can I fix this problem?
chatController.java
public class chatController{
@FXML Pane pane_chat_list,pane_chat_room;
public void initialize() {
pane_chat_list.setVisible(false);
pane_chat_room.setVisible(true);
}
public void isPressed(int a) {
if(a == 0) {
pane_chat_list.setVisible(true);
pane_chat_room.setVisible(false);
}else {
pane_chat_list.setVisible(false);
pane_chat_room.setVisible(true);
}
}
}
chat_list.java
public class chat_list{
@FXML Button chat_list_button;
chatController controll = new chatController();
public void initialize() {
chat_list_button.setOnAction(e -> back());
}
public void back() {
controll.isPressed(1);
}
}
chat_room.java
public class chat_room{
@FXML Button chat_room_back;
chatController controll = new chatController();
public void initialize() {
chat_room_back.setOnAction(e -> back());
}
public void back() {
controll.isPressed(0);
}
}