public void customize(DropdownList ddl) { ddl.setBackgroundColor(color(190)); ddl.setItemHeight(20); ddl.setBarHeight(15); ddl.captionLabel().set("pulldown"); ddl.captionLabel().style().marginTop = 3; ddl.captionLabel().style().marginLeft = 3; ddl.valueLabel().style().marginTop = 3; // for(int i=0;i<2;i++) { ddl.addItem("180 deg", 0); ddl.addItem("30 deg", 1); // } ddl.setColorBackground(color(60)); ddl.setColorActive(color(255, 128)); }
public void InitComDropdown() { // Initialize portCommList int posX = 20; int posY = 70; PortsList = controlP5.addDropdownList("portComList", posX, posY, 100, 84); // Set the background color of the list (you wont see this though). PortsList.setBackgroundColor(color(200)); // Set the height of each item when the list is opened. PortsList.setItemHeight(20); // Set the height of the bar itself. PortsList.setBarHeight(15); // Set the lable of the bar when nothing is selected. PortsList.captionLabel().set("Select COM port"); // Set the top margin of the lable. PortsList.captionLabel().style().marginTop = 3; // Set the left margin of the lable. PortsList.captionLabel().style().marginLeft = 3; // Set the top margin of the value selected. PortsList.valueLabel().style().marginTop = 3; // Store the Serial ports in the string comList (char array). comList = serial.list(); // We need to know how many ports there are, to know how many items to add to the list, so we // will convert it to a String object (part of a class). String comlist = join(comList, ","); // We also need how many characters there is in a single port name, we\u00b4ll store the chars // here for counting later. String COMlist = comList[0]; // Here we count the length of each port name. int size2 = COMlist.length(); // Now we can count how many ports there are, well that is count how many chars there are, so we // will divide by the amount of chars per port name. int size1 = comlist.length() / size2; // Now well add the ports to the list, we use a for loop for that. How many items is determined // by the value of size1. for (int i = 0; i < size1; i++) { // This is the line doing the actual adding of items, we use the current loop we are in to // determin what place in the char array to access and what item number to add it as. PortsList.addItem(comList[i], i); } // Set the color of the background of the items and the bar. PortsList.setColorBackground(color(60)); // Set the color of the item your mouse is hovering over. PortsList.setColorActive(color(255, 128)); }