How to use RadioButtonBuilder/DropDownBuilders?

I have the whole GUI setup, working buttons, my own ScreenController class, etc. The GUI works great, and I love how simple it is. BUT, I’m having troubles with some controls. How would I add an item to a drop down control through JavaBuilder? In the same token, how would I add items to a RadioButtonGroup? I’m without internet on my work computer but I have the Nifty Manual PDF. I tried everything I could and couldn’t figure it out. Any help is appreciated!

PS. By my luck it’ll be the easiest solution ever. :wink:

I can at least answer the first question: “how to add items to a drop down control with the JavaBuilder?” The answer is simple: You don’t. This is not supported. You’ll need to use the Listbox control API stuff to do this after the control has been created. This is explained in the Nifty wiki somewhere. This was supported some time ago with XML but it isn’t anymore. Since you can now add any class to the DropDown and not only Strings this feature has been removed. Sorry!

I’m pretty sure you can do that for the RadioButtonGroup tho with some groupId attribute or so, iirc. But I’m not sure and I can’t check right now since I’m in bed already :o

@Tumaini said:
[java]DropDownBuilder b = new DropDownBuilder("tankDropDown") {

Element e =, screen, parentElement);
DropDown<String> dropDown = e.getNiftyControl(DropDown.class);
Exchange String for another type if your drop down should hold another type.
1 Like

@void256 Thanks, you’d know best eh? lol. I’m whattapancake by the way, I’m really sorry I didn’t finish my control tutorial for the Nifty Wiki! I got backed up, found a girl, which caused me to abandon my house for the first time in who knows how long, and now I’m working on my own project. But, I will get back to it soon, hince my question here. Expect to see more questions and some finished tutorials at some point :stuck_out_tongue:

@perfecticus Thanks a ton! I’m not at my work computer but I will be sooner or later. To be ttally honestI never woulda guessed that. Hahaha. Thanks again!

@perfecticus it returns a NullPointerException from line 152 in DropDownControl.class. But there is no line 152 in said class. I think it’s because I have the nightly update from a few nights ago or so.

The reference page for the RadioButton control in the Nifty wiki explains about how you use this control and how you can attach it to a radio group. As far as I see it even has a JavaBuilder example code:.