Your problem has nothing to do with serialVersionUID
. Go ahead, delete that entire line; you'll see that you still need the braces.
Your problem is that you're writing code outside of any function. Therefore, Java considers it to be an instance initializer, and instance initializers must be surrounded by braces.
The easiest-to-understand solution is to create a constructor to contain your code:
public class HangmanPanel extends JPanel{
private static final long serialVersionUID = -1767262708330188227L;
public HangmanPanel () {
this.setLayout(null);
JLabel heading = new JLabel("Welcome to the Hangman App");
JButton Button = new JButton("Ok");
// and so on
From a purely behavioral perspective, adding an explicit constructor in this case does nothing: instance initializers are invoked as part of object construction. However, they are confusing (as you've shown by your question). Adding the constructor clears up the confusion.