Xml do synth look and feel

1 resposta
L

Senhores,

Comecei a me aventurar com o Synth LnF e estou recebendo o seguinte erro quando tento executar a aplicacao

java.text.ParseException: Error parsing: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed. null
	at javax.swing.plaf.synth.SynthParser.parse(Unknown Source)
	at javax.swing.plaf.synth.SynthLookAndFeel.load(Unknown Source)

o arquivo xml é bem simples… segue abaixo

<style id="default">
   <font name="Aharoni" size="14"/>
   <state>
      <color value="#FFFFFF" type="FOREGROUND"/>
   </state>
</style>
<bind style="default" type="region" key=".*"/>

o codigo q estou usando para iniciar a aplicacao é

SynthLookAndFeel synth = new SynthLookAndFeel();
    	try {
    		InputStream lnf = MinhaClasse.class.getClassLoader().getResourceAsStream("teste.xml");
			synth.load(lnf, MinhaClasse.class);
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	try {
			UIManager.setLookAndFeel(synth);
		} catch (UnsupportedLookAndFeelException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

alguem sabe me dizer o que pode estar acarretando esse erro?

[]'s
Leonardo

1 Resposta

T

XML tem de ter apenas um nó raiz. No seu caso, é “<synth>” (que você não incluiu.

&lt?xml version="1.0" encoding="UTF-8"?&gt
&lt;synth&gt;
&lt;style id="default"&gt;
    <font  size="14"/>
    &lt;state&gt;
       &lt;color value="#FFFFFF" type="FOREGROUND"/&gt;
    &lt;/state&gt;
 &lt;/style&gt;
 &lt;bind style="default" type="region" key=".*"/&gt;
&lt;/synth&gt;
Criado 24 de outubro de 2006
Ultima resposta 24 de out. de 2006
Respostas 1
Participantes 2