Skip to content
Advertisement

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!

JavaScript

}

Advertisement

Answer

  • Add frame.add(JScrollPane(table));
  • Change frame.add(label); to frame.add(label, BorderLayout.NORTH);
  • Move frame.setVisible(true); to the end of the main method
  • Remove frame.setSize(1000, 800); and frame.setResizable(false);
  • Add frame.pack() before frame.setVisible(true);

enter image description here

JavaScript

Personally, I always get out of a static context as soon as I can, it will just make life easier

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement