3
public class CLASSNAME{

    public static void main(String[] args) {
      JFrame frame = new JFrame("TITLE");
      frame.setSize(300,300);
      frame.setVisible(true);
    }
}

So, the code above keeps the window open and only closes it when you x out of it yet there is no loop to keep the program from closing. Can someone explain this to me? And do i need to make a loop?

Mykola
  • 3,343
  • 6
  • 23
  • 39
Ken Will
  • 53
  • 8
  • Swing runs an event loop behind the scenes in a non-daemon thread, and this is what keeps the program running. Please see [this link](http://stackoverflow.com/questions/7217013/java-event-dispatching-thread-explanation) for more details on how this works and what is happening. – Hovercraft Full Of Eels Jan 05 '16 at 22:00
  • Also please look at [this question and its detailed answer](http://stackoverflow.com/questions/29359725/where-is-the-java-swing-counterpart-of-getmessage-loop) for more on this same subject. – Hovercraft Full Of Eels Jan 05 '16 at 22:01

0 Answers0