You place Swing components on Containers or other Components. You mean should you put the code in a certain place? And what is this about scripts? That is a program not a script.
That is a very basic example you have found; it is the GUI equivalent of Hello World. At least it specifically starts the event despatch
thread (EDT).
No, don't put GUI assembling code in the main method. The main method
is for starting an application and should do nothing else. There are several place you can write code; I like to put it in the constructor for a GUI class. A method which sets up the GUI is another place you can put it.
I do not like extending GUI classes. You often have to override JLabel#paintComponent, but apart from that
you should be able to create a GUI without using any inheritance beyond what Swing already uses. That example does exactly that. It creates instances of the classes and adds them to one another. Spot on. And in a good location.
That createGUI method is old‑fashioned. In Java5 (2004) the add method was altered so there is no longer any need to write getContentPane(). Also the method for starting the EDT was greately simplified in Java8 (2014) so there is no need for the anonymous class any more. In fact Horstmann in
Core Java for the Impatient says you should no longer teach anonymous classes.
If you use Java8, you can change two of those statements to:-