I’ll just send all of my code.
import controlP5.*;
ControlP5 cp5;
DropdownList freezer, shelf, rack, box;
int cnt = 0;
PImage image5x5;
PImage image9x9;
int rowCount5x5;
int rowCount9x9;
int rowCount;
String[] freezerList;
String[] shelfList;
String[] rackList;
String[] boxList;
Table locationTable5x5;
Table locationTable9x9;
Table dataTable;
int slotNumber;
String title = "Freezer Lookup Tool";
String filePath;
Boolean x9 = true;
Boolean x5 = true;
void setup(){
size(1140, 900);
// Create buttons using controlP5 library
cp5 = new ControlP5(this);
cp5.addButton("x9").setValue(0).setPosition(830, 490).setSize(60, 60);
cp5.addButton("x5").setValue(0).setPosition(910, 490).setSize(60, 60);
cp5.addDropdownList("freezer").setPosition(830, 130);
cp5.addDropdownList("shelf").setPosition(830, 250).setSize(100, 40);
cp5.addDropdownList("rack").setPosition(830, 370).setSize(100, 40);
//cp5.addDropdownList("box").setPosition(830, 490).setSize(100, 40);
// Load grids that will be used for
// representing each cryobox
image5x5 = loadImage("5x5_grid.png");
image9x9 = loadImage("9x9_grid.png");
locationTable5x5 = new Table("loc_5x5.txt");
locationTable9x9 = new Table("loc_9x9.txt");
rowCount5x5 = locationTable5x5.getRowCount();
rowCount9x9 = locationTable9x9.getRowCount();
slotNumber = 1;
// Load .txt of inventory
dataTable = loadTable("Freezer Stock.csv");
rowCount = dataTable.getRowCount();
fillLists(rowCount);
}
// Create unique lists of value for dropdown menu
void draw(){
background(0);
background(192, 100, 100);
// Draw title background box
textSize(48);
fill(255, 200);
stroke(2);
rect(10, 10, textWidth(title) + 10, 63, 5);
noStroke();
// Draw Title
fill(0);
text(title, 10, 58);
// Draw image
//image(image9x9, 0, 90);
// Draw slot numbers on grid
//draw9x9();
if (x5) {
// If x9 was previously active, turn off
x9 = false;
image(image5x5, 0, 90);
draw5x5();
}
if (x9) {
// If x5 was previously active, turn off
x5 = false;
image(image9x9, 0, 90);
draw9x9();
}
smooth();
fill(0);
noStroke();
drawMenuBox();
}
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// ADDITIONAL FUNCTIONS //
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
void draw5x5(){
for (int row = 0; row < rowCount5x5; row++){
float x = locationTable5x5.getFloat(row, 0); // column 1
float y = locationTable5x5.getFloat(row, 1); // column 2
textSize(24);
text(row + 1, x + 4, y + 28);
}
}
void draw9x9(){
for (int row = 0; row < rowCount9x9; row++){
float x = locationTable9x9.getFloat(row, 0); // column 1
float y = locationTable9x9.getFloat(row, 1); // column 2
textSize(12);
text(row + 1, x + 4, y + 16);
}
}
void drawMenuBox(){
fill(255, 200);
stroke(2);
rect(820, 90, 310, 800, 5);
fill(0);
noStroke();
textSize(24);
text("Freezer", 830, 120);
text("Shelf", 830, 240);
text("Rack", 830, 360);
text("Box", 830, 480);
}
// Button Logic
public void x9(){
if(!x9){
x9 = true;
} else {
x9 = false;
}
}
// Button Logic
public void x5(){
if(!x5){
x5 = true;
} else {
x5 = false;
}
}
void fillLists(int rowCount){
// Initialize lists for dropdown menu
freezerList = new String[rowCount];
shelfList = new String[rowCount];
rackList = new String[rowCount];
boxList = new String[rowCount];
// Populate lists
freezerList = dataTable.getStringColumn("Freezer");
shelfList = dataTable.getStringColumn("Shelf");
rackList = dataTable.getStringColumn("Rack");
boxList = dataTable.getStringColumn("Box");
}