我使用Scene Builder生成一個FXML文件。我需要它包含一些cirillic文本。在Scene Builder中編碼
當我編輯該文件與場景生成器,我可以看到正常cirillic字母(screen 1)
compileing以及與此FXML文件上運行我的程序後,我可以看到不cirillic字母,但一些文物(screen 2)
但,您可以在screen 3上看到它的xml文件編碼是UTF-8。另外,你可以看到它保存在ANSI中。
我試着用其他編輯器(默認的eclipse和崇高的文本2)打開它,他們shoen編碼錯誤。 (screen 4和screen 5)
起初我試圖將它從ansi轉換爲utf-8(用記事本++)。
之後,eclipse和崇高文本2開始顯示cirillic字母,因爲他們必須是。
但是。場景構建了一個錯誤,當我試圖打開此文件與它:
Error loading file
C:\eclipse\workspace\pr\src\main\java\ru\i\ava\pr\test.fxml.
C:\eclipse\workspace\pr\src\main\java\ru\i\ava\pr\test.fxml:1: ParseError
at [row,col]:[1,1]
Message: Content is not allowed in prolog.
和Java編譯器給了我一個錯誤:
июн 08, 2012 8:11:03 PM javafx.fxml.FXMLLoader logException
SEVERE: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
/C:/eclipse/workspace/pr/target/classes/ru/i/ava/pr/test.fxml:1
at javafx.fxml.FXMLLoader.load(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at ru.i.ava.pr.PrFX.start(PrFX.java:22)
at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$3.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
at com.sun.glass.ui.win.WinApplication$2$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source)
at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javafx.fxml.LoadException: javax.xml.stream.XMLStreamException: ParseError at
[row,col]:[1,1]
Message: Content is not allowed in prolog.
at javafx.fxml.FXMLLoader.load(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at ru.i.ava.pr.PrFX.start(PrFX.java:22)
at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$3.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
at com.sun.glass.ui.win.WinApplication$2$1.run(Unknown Source)
... 1 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown Source)
at javax.xml.stream.util.StreamReaderDelegate.next(Unknown Source)
... 14 more
所以,我已經轉換回ANSI 。
而且,在ANSI中具有此文件時,會將其「artefacted」文本手動更改爲cirilic字母。
現在我可以看到普通的文本,當我運行我的程序,但是當我打開通過場景生成器這個固定的文件,
場景生成器會顯示我一些「artefacted」文本(screen 7)。
那麼,我該如何解決這種情況?
維多利亞,請接受你自己的答案,因爲你已經找到了解決方案。 –