11/*
2- * Copyright (c) 2023, 2024 , Oracle and/or its affiliates.
2+ * Copyright (c) 2023, 2025 , Oracle and/or its affiliates.
33 * All rights reserved. Use is subject to license terms.
44 *
55 * This file is available and licensed under the following license:
@@ -273,13 +273,12 @@ void open() {
273273 FileChooser ch = new FileChooser ();
274274 ch .setTitle ("Open File" );
275275 ch .getExtensionFilters ().addAll (
276- filterAll (),
277276 filterRich (),
278- filterRtf ()
277+ filterRtf (),
278+ filterAll ()
279279 );
280280
281- Window w = FX .getParentWindow (control );
282- File f = ch .showOpenDialog (w );
281+ File f = ch .showOpenDialog (parentWindow ());
283282 if (f != null ) {
284283 try {
285284 DataFormat fmt = guessFormat (f );
@@ -294,11 +293,12 @@ void save() {
294293 File f = getFile ();
295294 if (f == null ) {
296295 f = chooseFileForSave ();
297- if (f ! = null ) {
296+ if (f = = null ) {
298297 return ;
299298 }
300299 }
301300
301+ file .set (f );
302302 try {
303303 writeFile (f );
304304 } catch (Exception e ) {
@@ -309,7 +309,6 @@ void save() {
309309 boolean saveAs () {
310310 File f = chooseFileForSave ();
311311 if (f != null ) {
312- // TODO ask to overwrite if file exists
313312 file .set (f );
314313 try {
315314 writeFile (f );
@@ -333,10 +332,9 @@ private File chooseFileForSave() {
333332 filterRich (),
334333 filterRtf (),
335334 filterTxt ()
336- //filterAll()
337335 );
338- Window w = FX . getParentWindow ( control );
339- return ch .showSaveDialog (w );
336+
337+ return ch .showSaveDialog (parentWindow () );
340338 }
341339
342340 private void readFile (File f , DataFormat fmt ) throws Exception {
@@ -500,7 +498,7 @@ enum UserChoiceToSave {
500498
501499 private UserChoiceToSave askSaveChanges () {
502500 Dialog <UserChoiceToSave > d = new Dialog <>();
503- d .initOwner (FX . getParentWindow ( control ));
501+ d .initOwner (parentWindow ( ));
504502 d .setTitle ("Save Changes?" );
505503 d .setContentText ("Do you want to save changes?" );
506504
@@ -540,4 +538,8 @@ public boolean askToSave() {
540538 }
541539 return false ;
542540 }
541+
542+ private Window parentWindow () {
543+ return FX .getParentWindow (control );
544+ }
543545}
0 commit comments