Thanks for the suggestions guys, i tried adding in the label and textfield into a new panel and then adding that new panel to the gui as a whole. So i have the panel that contains the dropdown box/label and then the textfield one.
Here's what I end up with
private void createGUI(){
final int guiWidth = 350, guiHieght = 150;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
// Calculating x and y coordinates
final int gX = (int) (screenSize.getWidth() / 2) - (guiWidth / 2);
final int gY = (int) (screenSize.getHeight() / 2) - (guiHieght / 2);
// create a new JFrame with the title "GUI"
gui = new JFrame("GUI");
// set the x coordinate, y coordinate, width and height of the GUI
gui.setBounds(gX, gY, guiWidth, guiHieght);
gui.setResizable(true);
// Create a sub container JPanel
JPanel panel = new JPanel();
JPanel panel1 = new JPanel();
gui.add(panel);
gui.add(panel1);
JLabel label = new JLabel("Select a food type:"); // create a label
JLabel label1 = new JLabel("Enter Mob Name");
label.setForeground(Color.white);
label1.setForeground(Color.white);
panel.add(label); // add it to the JPanel
panel1.add(label1);
// create a select box for food options
JComboBox<String> foodSelector = new JComboBox<>(new String[]{"Shrimps", "Trout", "Salmon","Lobster", null});
JTextField mobName = new JTextField();
// add an action listener, to listen for user's selections, assign to a variable called selectedFood on selection.
foodSelector.addActionListener(e -> selectedFood = foodSelector.getSelectedItem().toString());
// add the select/text-field box to the JPanel panels
panel.add(foodSelector);
panel1.add(mobName);
JButton startButton = new JButton("Start");
// add an action listener to the button
startButton.addActionListener(e -> { // This code is called when the user clicks the button
started = true; // Set the boolean variable started to true
gui.setVisible(false); // Hide the GUI
});
panel.add(startButton); // Add the button to the panel
gui.setVisible(true); //makes GUI visible
}
Here is my code for the GUI, I think my problem may just be the panels are on top of each other but im not sure?