[Solved] Xml problem with checkbox

i can´t put my xml work correctly only me give the last value
and put in all checkbox the last value
this is my code
xml file

<?xml version="1.0"?>
<gameoptions>
    
     <opcao id="1">
        <name>Your Name</name>
        <value>true</value>	
    </opcao>
    
    <opcao id="2">
        <name>Group Friend</name>
        <value>true</value>	
    </opcao>
    
    <opcao id="3">
        <name>Alliance Name</name>
        <value>true</value>	
    </opcao>
    
    <opcao id="4">
        <name>NPC Names</name>
        <value>true</value>
		
    </opcao>
    
    <opcao id="5">
        <name>Friends Names</name>
        <value>true</value>	
    </opcao>
    
    <opcao id="6">
        <name>Enemy Names</name>
        <value>true</value>	
    </opcao>
    
    <opcao id="7">
        <name>Display Monsters Names</name>
        <value>false</value>
    </opcao>
    
</gameoptions>

configuration.java

public List<configuration>le() {

        List<configuration> Historico = new ArrayList<configuration>();

        try {

            File fXmlFile = new File("Game_Options.xml");
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(fXmlFile);

            //optional, but recommended
            //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
            doc.getDocumentElement().normalize();

            System.out.println("Root element :" + doc.getDocumentElement().getNodeName());

            NodeList nList = doc.getElementsByTagName("opcao");

            System.out.println("----------------------------");

            for (int temp = 0; temp < nList.getLength(); temp++) {

                Node nNode = nList.item(temp);

             //   System.out.println("\nCurrent Element :" + nNode.getNodeName());

                if (nNode.getNodeType() == Node.ELEMENT_NODE) {

                    Element eElement = (Element) nNode;
 
               //     System.out.println("Game options id : " + eElement.getAttribute("id"));
                 //   System.out.println("Name opção : " + eElement.getElementsByTagName("name").item(0).getTextContent());
                  //  System.out.println("value : " + eElement.getElementsByTagName("value").item(0).getTextContent());
                    configuration ola = new  configuration();
                    ola.setcodocao(eElement.getAttribute("id"));
                    ola.setnome(eElement.getElementsByTagName("name").item(0).getTextContent());
                   
                    ola.setValidacao(eElement.getElementsByTagName("value").item(0).getTextContent());

// System.out.println(nome_opcao);
 //System.out.println( validade);
  Historico.add(ola);
  
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
         return Historico;
    }

try {
            List<configuration> piloto = new configuration().le();

            Iterator<configuration> pilotopro = piloto.iterator();

            while (pilotopro.hasNext()) {
                configuration config = pilotopro.next();
              //  p.getcodigoopcao();
               // p.getnome();
              //  t = Boolean.parseBoolean(p.getvalidacao());
             System.err.println("Codigo de Opcao"+ config.getcodigoopcao());
             System.err.println("Nome de Opcao"+    config.getnome());
             System.err.println("Validação de Opcao"+config.getvalidacao()); 
   
       

        loginPanel = new Container();

        Label fg = loginPanel.addChild(new Label("Options", new ElementId("title")));

        fg.setBackground(null);
        Container props = loginPanel.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X, FillMode.None, FillMode.Last)));
        props.setBackground(null);

        TabbedPanel tabs = new TabbedPanel();
        tab1 = tabs.addTab("Game Options", new Container(new SpringGridLayout(Axis.X, Axis.Y)));
        Container name = tab1.addChild(new Container());

        Label o = name.addChild(new Label("Name", new ElementId("title")));
        o.setBackground(null);
        Name = name.addChild(new Checkbox("Your Name"));
        Group = name.addChild(new Checkbox("Group Friend"));
        Aliance = name.addChild(new Checkbox("Alliance Name"));
        NPC = name.addChild(new Checkbox("NPC Names"));
        friends = name.addChild(new Checkbox("Friends Names"));
        Enemy = name.addChild(new Checkbox("Enemy Names"));
        Monsters = name.addChild(new Checkbox("Display Monsters Name"));
        Name.setChecked(config.getvalidacao()); devia ser verdadeiro e me da falso

        Group.setChecked(config.getvalidacao()); 
        Aliance.setChecked(config.getvalidacao());
        NPC.setChecked(config.getvalidacao());
        friends.setChecked(config.getvalidacao());
        Enemy.setChecked(config.getvalidacao());
        Monsters.setChecked(config.getvalidacao()); 
                   }

        } catch (Exception ex) {
        }

What GUI language is this? That doesn’t seem to be nifty or something. Could you please tell us what are you working with!

i working with lemur
sorry i forget the say it
and i using xml to read and save value of checkbox

Lemur doesnt and isnt binding with your xml file, and you havent bound the checkbox or anything else to a field or method.

Take a look at these appstates to see how to bind gui elements.

So, your problem is either that Lemur is ignoring these setChecked() methods or that your getvalidacao() methods is returning false. I know which one I vote for… but it’s easy to test. Swap out when with a setChecked(true) and see if it gets checked.

Or just do some basic debugging by stepping through the code in the debugger or using System.out.println() to see that the values are what you expect.

I’m making a lot of assumptions, though. I don’t know what effect you are trying to achieve or what effect you are seeing. You’ve said things are wrong but you haven’t actually said how they are wrong.

The problem it´s is put my checkbox the last value of my xml file
becouse when i put Name.setText(config.getnome());
i give-me this result the checkbox name is Display Monsters Names

but i only use this code

           while (pilotopro.hasNext()) {
                configuration config = pilotopro.next();
                 System.err.println("Codigo de Opcao"+ config.getcodigoopcao());
             System.err.println("Nome de Opcao"+    config.getnome());
             System.err.println("Validação de Opcao"+config.getvalidacao()); 
}

works fine
give this result
Code of Option: 1
Name of Options: Your Name
Code Validation:true

Code of Option: 7
Name of Options: Display Monsters Names
Code Validation:false

You are setting all of the checkboxes to the same value in the code you posted.

Beyond that, I can’t really help. The code is a complete mess and very hard to read. You should really consider following standard Java conventions as it will help others be able to read your code.

i find the soluction
maybe not the best but works

while (pilotopro.hasNext()) {
                configuration config = pilotopro.next();

                  System.err.println("Codigo de Opcao "+ config.getcodigoopcao());
                    System.err.println("Nome de Opcao "+    config.getnome());
                    System.err.println("Validação de Opcao "+config.getvalidacao()); 
             
                    if (config.getcodigoopcao().equals("1")) {
                    Name.setChecked(config.getvalidacao());
                }
                if (config.getcodigoopcao().equals("2")) {
                    Group.setChecked(config.getvalidacao());
                    // System.out.println(config.getvalidacao());
                }
                if (config.getcodigoopcao().equals("3")) {
                    Aliance.setChecked(config.getvalidacao());
                }
                if (config.getcodigoopcao().equals("4")) {
                    NPC.setChecked(config.getvalidacao());
                }
                if (config.getcodigoopcao().equals("5")) {
                    friends.setChecked(config.getvalidacao());
                }
                if (config.getcodigoopcao().equals("6")) {
                    Enemy.setChecked(config.getvalidacao());
                }
                if (config.getcodigoopcao().equals("7")) {
                    Monsters.setChecked(config.getvalidacao());
                }

            }