Fixed problem of when to call setLayout()