I don't understand why my labels are not coming up when i run the code are the JComboBox to big or what?

import javax.swing.*;
//import javax.swing.AbstractButton;

import java.awt.*;
//import java.awt.event.ActionEvent;
//import java.awt.event.ActionListener;

public class floralOrderGUI {

    JButton submitButton = new JButton("Submit");

	public static void main(String[] args) {            

            new floralOrderGUI();
		//system.exit(Q);
	}

	public floralOrderGUI(){
		JFrame mainFrame = new JFrame ("mobileOrders");
		mainFrame.setSize (300, 300);
		mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		mainFrame.setLayout(new GridLayout (3,2,5,5));

	//create components for the window
		JLabel mobileOrdersInputLabel = new JLabel("Menu Choice", SwingConstants.RIGHT);
		JLabel floralOrdersInputLabel = new JLabel("Floral Orders", SwingConstants.RIGHT);


		JTextField numInput = new JTextField();
		numInput.setBackground(new Color (255, 199, 64));
		numInput.setForeground(new Color(176, 165, 50));
		numInput.setBackground(new Color(184, 120, 85));
		numInput.setForeground(new Color(184, 120, 85));
		JComboBox menuChoice = new JComboBox();
		JComboBox paymentOption = new JComboBox();
		JComboBox dFlowerOption = new JComboBox();
                JComboBox deliveryOption = new JComboBox();
		numInput.setBackground(new Color (255, 199, 64));
		numInput.setForeground(new Color(184, 120, 85));


		String floralOption[] ={ "Cut Flowers = $15.00","Floral Arrangemen = $25.00t","Coursages = 10.00","None"};

		for (int i= 0; i<=3; i++)
		     menuChoice.addItem(floralOption[i]);

		numInput.setBackground(new Color(250, 190, 60));
		numInput.setForeground(new Color(180, 129, 80));
		//gain access to the window container
		//Container c = mainFrame.getContentPane();

		String dominantFlower[] = { "Roses = $5.00", "Daisies", "Chrysanthemums", "Irises"};

		for (int j= 0; j<=3; j++)
			dFlowerOption.addItem(dominantFlower[j]);

		numInput.setBackground(new Color(250, 190, 60));
		numInput.setForeground(new Color(180, 129, 80));
		//gain access to the window container
		//Container c = mainFrame.getContentPane();




		String payment[] ={ "Cash", "Cheque", "Credit Card"};

                for (int k= 0; k<=2; k++)
                        paymentOption.addItem(payment[k]);

		numInput.setBackground(new Color(250, 190, 60));
		numInput.setForeground(new Color(180, 129, 80));
		//gain access to the window container
		//Container c = mainFrame.getContentPane();


                String dOption[]= { "Drop Off = $10.00", "Pick Up"};

                for (int L= 0; L<=1; L++)
                    deliveryOption.addItem(dOption[L]);

                numInput.setBackground(new Color(250, 190, 60));
		numInput.setForeground(new Color(180, 129, 80));
		//gain access to the window container
		Container c = mainFrame.getContentPane();


		//add element to the window container

		//c.add(mobileOrdersInputLabel);
		//c.add(floralOrdersInputLabel);
                c.add(submitButton);
		c.add(menuChoice);
                c.add(dFlowerOption);
                c.add(paymentOption);
                c.add(deliveryOption);
		mainFrame.setVisible(true);
               // c.setVisible(true);


	}

}
//c.add(mobileOrdersInputLabel);
		//c.add(floralOrdersInputLabel);

What happens when you uncomment these?

You need to look into how to use layout managers.

Edited 6 Years Ago by NormR1: n/a

This question has already been answered. Start a new discussion instead.