With Swing, I had a class like this:
public class MyFrame extends JFrame {
private static final String APP_NAME = "My App";
// ...
@Override
public void setTitle(String newTitle) {
super.setTitle(newTitle == null || newTitle.isEmpty() ? APP_NAME : newTitle + " - " + APP_NAME);
}
}
This would guarantee the title always contains the app name, like "Editing - My App".
I attempted to replicate this behavior in JavaFX by attaching a custom ChangeListener<String> to the #titleProperty() of the scene, but quickly fell short when I couldn't find a way to intercept and change the value before it appeared on the window, at least not without infinite recursion.
Aucun commentaire:
Enregistrer un commentaire