This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Hi When switching to GUI designer of JForm, JPanel and other presets for .java files which allow useage of GUI designer, following error appears: The form file does not contain valid XML. The form cannot be opened. Content is not allowed in prolog. The JFrame.form file contains something like this: < ? x m l v e r s i o n = " 1 . 0 " e n c o d i n g = " U T F - 8 " ? > < F o r m v e r s i o n = " 1 . 3 " t y p e = " o r g . n e t b e a n s . m o d u l e s . f o r m . f o r m i n f o . J F r a m e F o r m I n f o " > < P r o p e r t i e s > < P r o p e r t y n a m e = " d e f a u l t C l o s e O p e r a t i o n " t y p e = " i n t " v a l u e = " 3 " / > < / P r o p e r t i e s > < S y n t h e t i c P r o p e r t i e s > < S y n t h e t i c P r o p e r t y n a m e = " f o r m S i z e P o l i c y " t y p e = " i n t " v a l u e = " 1 " / > < / S y n t h e t i c P r o p e r t i e s > < L a y o u t > < D i m e n s i o n L a y o u t d i m = " 0 " > < G r o u p t y p e = " 1 0 3 " g r o u p A l i g n m e n t = " 0 " a t t r i b u t e s = " 0 " > < E m p t y S p a c e m i n = " 0 " p r e f = " 4 0 0 " m a x = " 3 2 7 6 7 " a t t r i b u t e s = " 0 " / > < / G r o u p > < / D i m e n s i o n L a y o u t > < D i m e n s i o n L a y o u t d i m = " 1 " > < G r o u p t y p e = " 1 0 3 " g r o u p A l i g n m e n t = " 0 " a t t r i b u t e s = " 0 " > < E m p t y S p a c e m i n = " 0 " p r e f = " 3 0 0 " m a x = " 3 2 7 6 7 " a t t r i b u t e s = " 0 " / > < / G r o u p > < / D i m e n s i o n L a y o u t > < / L a y o u t > < / F o r m > This does happen only in case of newly created projects. Creating a JForm file in the old ones works fine and the .form file is not corrupted. This happens in case of every newly created project. I tried to reinstall NetBeans but it didn't help.
Looks like the form file was saved in unicode (utf-16) but not read as such. I can reproduce it by setting project encoding to utf-16. As a workaround, setting the project encoding to utf-8 could help. Are your new projects created with utf-16 by default? Might be a JDK issue if it claims it is the default platform encoding. You can try to add -J-Dfile.encoding=UTF-8 to netbeans_default_options parameter in the netbeans.conf file, then new projects should hopefully be created with utf-8 as well. Anyway, GUI forms xml should always be saved in utf-8, that is a bug.
Switching the project encoding to UTF-8 helps. Default encoding for a new project is UTF-32. Using GUI designer with windows-1250 encoding works fine.
During form creation all template files go through a scripting engine and are written down in the actual project encoding. For the form file there is no need for any template processing (unlike with java file). I've made a fix that does just a plain file copy that preserves the utf-8 encoding. http://hg.netbeans.org/jet-main/rev/96d37de8a7a7
Integrated into 'main-silver', will be available in build *201601060002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/96d37de8a7a7 User: Tomas Pavek <tpavek@netbeans.org> Log: #257366: handle form file creation from template as plain file copy, avoiding writing in other than utf-8 encoding