-
Notifications
You must be signed in to change notification settings - Fork 0
/
FixJavaFX.py
32 lines (21 loc) · 1.11 KB
/
FixJavaFX.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# This script can be run from any location
# It fixes all "incorrect versions error" of JavaFX in FXML files, making all the related warnings disappear
# REMEMBER TO CHANGE THE PATH AND POSSIBLY THE JAVAFX VERSIONS AS WELL
import os
def replace_string_in_files(directory, old_string, new_string):
for subdir, _, files in os.walk(directory):
for filename in files:
if not filename.endswith('.fxml'):
continue
filepath = os.path.join(subdir, filename)
with open(filepath, 'r') as file:
filedata = file.read()
filedata = filedata.replace(old_string, new_string)
with open(filepath, 'w') as file:
file.write(filedata)
directory = 'C:\\\path\\\to\\\your\\\view\\\folder'
# Version installed where files are saved by SceneBuilder
currentVersion = 'xmlns="http://javafx.com/javafx/19"'
# Correct version according to IntelliJ to make error messages disappear
correctVersion = 'xmlns="http://javafx.com/javafx/17.0.6"'
replace_string_in_files(directory, currentVersion, correctVersion)