Popup Message boxes

ão tenho certeza de como codificar a caixa de mensagem pop-up nos meus método

public String verify(){
    String result = "failed";
    int authcode = staffBean.getVerifyCodeByName(getLoginUserName());

    if (code == authcode){       
        result ="success";
    } ,   
    else{ //statement to popup an error message box

    }
    return result;
}

Eu tentei usarJOptionPane no meu método, mas não funciona:

String st = "Welcome";
JOptionPane.showMessageDialog(null, st);

questionAnswers(8)

yourAnswerToTheQuestion