public void setPanel(PanelType t, List<Object> args) {
if (args == null) {
args = new LinkedList<Object>();
}
Panel p = (Panel) content.getChildren().get(0);
try {
p.close();
} catch (SQLException e) {
e.printStackTrace();
}
content.getChildren().remove(0);
Panel panel = null;
args.add(0, results);
switch (t) {
case RootPanel:
args.add(1, this);
panel = new RootPanel();
break;
case LoginPanel:
args.add(1, this);
panel = new LoginPanel();
break;
case UserPanel:
panel = new UserPanel();
break;
case ReceptionPanel:
panel = new ReceptionPanel();
break;
case RegisterPanel:
args.add(1, this);
panel = new RegisterPanel();
break;
case FinancePanel:
panel = new FinancePanel(this, args);
break;
case PersonnelPanel:
panel = new PersonnelPanel(this);
break;
case StatisticsPanel:
panel = new StatisticsPanel(this);
break;
case RootSearchPanel:
panel = new RootSearchPanel(this);
break;
case CleaningPanel:
panel = new CleaningPanel(results);
break;
default:
throw new IllegalArgumentException("undefined panel");
}
try {
panel.connect();
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
panel.create(args);
HBox.setHgrow((Node) panel, Priority.ALWAYS);
content.getChildren().add(0, (Node) panel);
}