Refactoring the codes for JavaFX implementation