'How do I make it so that the table is displayed inside the JFrame in Main?

I am currently making a program for my school project, it is a fast food order calculator, my problem is that I have to be able to display the table inside the JFrame in Main, if I add "frame.add(table);" inside Main, nothing happens. Any help would be appreciated, thank you!

JTable table;
JTable FastFoodCalculatorProgramming;

public FastFoodCalculatorProgramming() {
    setLayout(new FlowLayout());
    String[] columnNames = {"Product", "Description", "Item Price"};
    Object[][] data = {
        {"Product1", "Description1", "Price1"},
        {"Product2", "Description2", "Price2"},
        {"Product3", "Description3", "Price3"},
        {"Product4", "Description4", "Price4"},
        {"Product5", "Description5", "Price5"},
        {"Product6", "Description6", "Price6"},
        {"Product7", "Description7", "Price7"},
        {"Product8", "Description8", "Price8"},};

    table = new JTable(data, columnNames) {
        public boolean isCellEditable(int data, int columnNames) {
            return false;
        }
    };
    table.setPreferredScrollableViewportSize(new Dimension(500, 250));
    table.setFillsViewportHeight(true);

    JScrollPane scrollPane = new JScrollPane(table);
    add(scrollPane);

}

public static void main(String[] args) {

    FastFoodCalculatorProgramming table = new FastFoodCalculatorProgramming();
    table.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    table.setSize(600, 200);
    table.setVisible(true);
    table.setTitle("Fast Food Order Calculator");

    JLabel label = new JLabel();
    label.setText("Welcome to Fast Food Calculator!");
    label.setFont(new Font("Century Gothic", Font.BOLD, 30));
    label.setVerticalAlignment(JLabel.TOP);
    label.setHorizontalAlignment(JLabel.CENTER);
    label.setBorder(new EmptyBorder(20, 0, 0, 0));
    JFrame frame = new JFrame();
    frame.setVisible(true);
    frame.setSize(1000, 800);
    frame.setResizable(false);
    frame.setTitle("Fast Food Calculator");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setBackground(Color.gray);
    frame.add(label);
}

}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source