Your code doesn't define what 'this' is, but I presume it is a JFrame (for future reference, to avoid confusion post an SSCCE). If you add components to a container (JFrame) after it is realized...