A quick explanation of the code above.
the class board extends JPanel thefore it is a JPanel. In the constructor for board, it creates a JFrame (Window) sets the size of the frame, title, background and close operation (what happens when the window is exited). It then creates the "snake" which is a JComponent (Panel, Button, Label ...) and adds that to the frame. The frame is then made visible.
Thanks. I didn't knew you cann add JFrame to JPanel. I only knew the opposite