-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Code JavaFX
Tobias Diez edited this page Dec 11, 2016
·
20 revisions
-
View model converts the data from
logic
andmodel
in a form that is easily usable in the gui. - The only purpose of the View is to load and display the fxml file.
- The Controller initializes the view model and binds it to the view. In an ideal world all the binding would already be done directly in the fxml. But JavaFX's binding expressions are not yet powerful enough to accomplish this.
The only class which uses model
and logic
classes is the ViewModel
. Controller
and View
only access the ViewModel
and never the backend.
- The view model should derive from
AbstractViewModel
.
public class MyDialogViewModel extends AbstractViewModel {
}
- Add a (readonly) property as a private field and generate the getters:
private final ReadOnlyStringWrapper heading = new ReadOnlyStringWrapper();
public ReadOnlyStringProperty headingProperty() {
return heading.getReadOnlyProperty();
}
public String getHeading() {
return heading.get();
}
- Create constructor which initializes the fields to their default values. Write tests to ensure that everything works as expected!
public MyDialogViewModel(Dependency dependency) {
this.dependency = Objects.requireNonNull(dependency);
heading.set("Hello " + dependency.getUserName());
}
- Add methods which allow interaction. Again, don't forget to write tests!
public void shutdown() {
heading.set("Goodbye!");
}
public class AboutDialogController extends AbstractController<AboutDialogViewModel>
@FXML protected Button closeButton;
@FXML protected ImageView iconImage;
@Inject private DialogService dialogService;
@FXML
private void initialize() {
viewModel = new AboutDialogViewModel(dialogService, clipBoardManager, buildInfo);
}
@FXML
private void openJabrefWebsite() {
viewModel.openJabrefWebsite();
}
- Home
- General Information
- Development
- Please go to our devdocs at https://devdocs.jabref.org
- GSoC 2025 ideas list
- Completed "Google Summer of Code" (GSoC) projects
- GSoC 2024 ‐ Improved CSL Support (and more LibreOffice‐JabRef integration enhancements)
- GSoC 2024 - Lucene Search Backend Integration
- GSoC 2024 ‐ AI‐Powered Summarization and “Interaction” with Academic Papers
- GSoC 2022 — Implement a Three Way Merge UI for merging BibTeX entries
- GSoC 2021 - Improve pdf support in JabRef
- GSoC 2021 - Microsoft Word Integration
- GSoc 2019 - Bidirectional Integration — Paper Writing — LaTeX and JabRef 5.0
- GSoC Archive
- Release
- JabCon Archive