Problem myproblem;
in
Contributed Library Questions
•
1 year ago
Hi all. I'm trying to use the 'listbox' in the controlP5 library. My issue is the I want to select an item from the listbox and use it to determine a value.
- ListBox RESOLUTION;
- ///////////////////
- RESOLUTION = controlP5.addListBox("RESOLUTION",100,425,80,120);
- RESOLUTION.setItemHeight(15);
- RESOLUTION.setBarHeight(15);
- RESOLUTION.actAsPulldownMenu(true);
- RESOLUTION.captionLabel().set("RESOLUTION (DPI)");
- RESOLUTION.captionLabel().style().marginTop = 3;
- RESOLUTION.valueLabel().style().marginTop = 3; // the +/- sign
- RESOLUTION.addItem("72",1);
- RESOLUTION.addItem("150",1);
- RESOLUTION.addItem("240",1);
- RESOLUTION.addItem("300",1);
- RESOLUTION.addItem("360",1);
- RESOLUTION.addItem("400",1);
- RESOLUTION.addItem("600",1);
- RESOLUTION.addItem("720",1);
- RESOLUTION.addItem("800",1);
- RESOLUTION.addItem("1200",1);
- RESOLUTION.addItem("2400",1);
- RESOLUTION.addItem("3200",1);
- RESOLUTION.addItem("4800",1);
- RESOLUTION.addItem("6400",1);
- RESOLUTION.addItem("9600",1);
- RESOLUTION.addItem("12800",1);
- RESOLUTION.setColorBackground(color(255,128));
- RESOLUTION.setColorActive(color(0,0,255,128));
- //////////////////////////////////////////////
- double resolution = Double.parseDouble(WHAT DO I TYPE HERE TO GET THE VALUE FROM THE LISTBOX???); //////////////////////////////////////////////////////////// <----- THE PROBLEMATIC PART OF THE CODE
- System.err.println("PARSE RESOLUTION : "+resolution);
- source.setResolution(resolution);
- System.err.println("RESOLUTION DPI : "+source.getResolution());
My question is how do I retrieve the value from the listbox? I was thinking something along the lines of "RESOLUTION.stringValue()" but this doesn't seem to work.
The bit "source.setResolution( );" likes 'doubles' so I need to convert the string from the listbox into a double using "parsedouble". Is this correct? Is the output from the listbox a string?
Any help would be greatly appreciated.
Kind Regards, Arthur
1