samedi 25 août 2018

Labels in a loop and random numbers, please help, I tried every things [on hold]

I'm studying java and i have a trouble...

I'm trying to do a loop with labels and random numbers. I want that the loop make the labels and choose 2 types of random number for each label. and the label should to be show on my GUI panel.

I'm stuck guys, please help-me

My main class:

public class randomNumbers {
    int labels[] = new int [30];
    int numbersType1[] = {0, 0};
    int numbersType2[] = {0, 0};   




public void randomNumbers(){

    Random rand = new Random();
    int s;
    int g = 1;    
    int c = 1;          
    for( c = 1; c <= labels.length; c++){

     for (g = 1; g <= 5 ; g++){
     numbers[0] = 1 + rand.nextInt(99);
     numbers[1] = 1 + rand.nextInt(99);
    }
     for (s = 0; s <= 2; s++){
     stars[0] = 1 + rand.nextInt(99);
     stars[1] = 1 + rand.nextInt(99);

           }   

    }}}

And now my Layout code:

private class generateNumberActionListener implements ActionListener {
    @Override
    public void actionPerformed(ActionEvent e) {
        randomNumbers rand = new randomNumbers();   
        String label = rand.numbers[0]+" "+rand.numbers[1]+ " "+rand.numbers[2]+" "+rand.numbers[3]+" "+rand.numbers[4]+" | *"+rand.stars[0]+" *"+rand.stars[1]+"\n";     
        int choise = Integer.parseInt(JOptionPane.showInputDialog("Put here"));
        int c;

        for (c =1; c <= choise; c++){
          labelShow1.setText(""I'M STUCK!!!")
        }
        }
        }




Aucun commentaire:

Enregistrer un commentaire