1

I want to create method who get radio button and marked this when other radio button will be marked. Here is my nifty gui example menu:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<nifty>
    <useControls filename="nifty-default-controls.xml"/>
    <useStyles filename="nifty-default-styles.xml"/>
    <screen id="ustawieniaWyswietlania" controller="PakietyPodstawowe.Kontroler.KontrolerUstawieƄWyƛwietlania">
        <layer id="GLayer0" childLayout="center">
            <control id="r1" name="radioButtonGroup"/>
            <panel id="GPanel0" childLayout="absolute" width="100%" x="210" y="257" style="nifty-panel-simple" height="100%">
                <control name="radioButton" id="GRadioButton0" group="r1" x="193" y="236"/>
                <control name="radioButton" id="GRadioButton1" group="r1" x="327" y="244"/>
            </panel>
        </layer>
    </screen>
</nifty>

My method:

@NiftyEventSubscriber(pattern="GRadioButton.*")
public void setSelected(final String id, final RadioButtonStateChangedEvent event) {
        IO.drukujL(event.getRadioButton().getElement().getId());
        Element element = screen.findElementByName("GRadioButton1");
//      element.setMarkted(); this method I can't find
}

Maybe this problem is simply but I don't know how to mark automatically GRadioButton1 when GRadioButton0 is marked.

1 Answers1

1

You'll need to use a different method to get access to the RadioButton control API.

Use something like:

RadioButton radioButton = screen.findNiftyControl("GRadioButton1", RadioButton.class);
radioButton.select();

You might want to read chapter "11 Controls" in the Nifty GUI PDF Manual. And there is a Radiobutton reference in the wiki and the RadioButton JavaDoc might help as well.

Please note that the wiki was written for 1.3.x but most of the information should still be valid for 1.4.x

void256
  • 1,286
  • 10
  • 11