lundi 26 mars 2018

I am trying to make the code to make the next page randomized

I am a beginner on java. I need help on how to make the codes making the sequence of JPanels to be random. I have 10 Jpanels named as P1, P2, P3 to P10

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    String ans = text.getText();

    if (ans.equals("Uruguay"))
    {
        JOptionPane.showMessageDialog(null, "Your Answer is Correct", "Congradulations!", JOptionPane.PLAIN_MESSAGE);
        scount++;
        text.setText(null);
        P1.setVisible(false);
        P2.setVisible(true);


    }
     else if (ans.contains(""))
    {
        rcount++;
        JOptionPane.showMessageDialog(null, "Sorry, your answer is incorrect", "Incorrect Answer", JOptionPane.ERROR_MESSAGE);
        text.setText(null);
        P1.setVisible(false);
        P2.setVisible(true);
    }  
        Gamescore();
}    




Aucun commentaire:

Enregistrer un commentaire