进行内部方法调用时,ActionPerformed方法停止工作

时间:2019-02-07 19:42:26

标签: java netbeans

我是Java的新手,并试图通过制造“老虎机”来更好地学习它。 基本上,当我对andraBalans()方法进行内部方法调用(用于更改每次旋转的平衡)时,我的“ Spinbutton”的actionPerformed方法将在其上重新放置带有图标的标签而停止工作。 我该怎么解决?

 private void andraBalans()
 {
    int spelSumma = (int) betSize.getValue();
    int nySumma = Integer.parseInt(balance.getText());
    int nySumma2 = nySumma - spelSumma;

    balance.setText(Integer.toString(nySumma2));
  }

   private void spinActionPerformed(java.awt.event.ActionEvent evt) {                                     


    andraBalans();


    int slumpatTal = randomg.nextInt(6) + 1;
    int slumpatTal2 = randomg.nextInt(6) + 1;
    int slumpatTal3 = randomg.nextInt(6) + 1;

    //Slumpa för Reel 1
    if (slumpatTal == 1) {
        rad1lbl1.setLocation(46, 50);
        rad1lbl2.setLocation(46, 192);
        rad1lbl3.setLocation(46, 348);

    } else if (slumpatTal == 2) {
        rad1lbl1.setLocation(46, 192);
        rad1lbl2.setLocation(46, 50);
        rad1lbl3.setLocation(46, 348);
    } else if (slumpatTal == 3) {
        rad1lbl1.setLocation(46, 348);
        rad1lbl2.setLocation(46, 192);
        rad1lbl3.setLocation(46, 50);
    } else if (slumpatTal == 4) {
        rad1lbl1.setLocation(46, 192);
        rad1lbl2.setLocation(46, 50);
        rad1lbl3.setLocation(46, 348);
    } else if (slumpatTal == 5) {
        rad1lbl1.setLocation(46, 50);
        rad1lbl2.setLocation(46, 348);
        rad1lbl3.setLocation(46, 192);
    } else if (slumpatTal == 6) {
        rad1lbl1.setLocation(46, 50);
        rad1lbl2.setLocation(46, 192);
        rad1lbl3.setLocation(46, 348);
    }

    //Slumpa för Reel 2
    if (slumpatTal2 == 1) {
        rad2lbl1.setLocation(273, 50);
        rad2lbl2.setLocation(273, 189);
        rad2lbl3.setLocation(273, 348);
    } else if (slumpatTal2 == 2) {
        rad2lbl1.setLocation(273, 189);
        rad2lbl2.setLocation(273, 50);
        rad2lbl3.setLocation(273, 348);
    } else if (slumpatTal2 == 3) {
        rad2lbl1.setLocation(273, 189);
        rad2lbl2.setLocation(273, 348);
        rad2lbl3.setLocation(273, 50);
    } else if (slumpatTal2 == 4) {
        rad2lbl1.setLocation(273, 348);
        rad2lbl2.setLocation(273, 50);
        rad2lbl3.setLocation(273, 189);
    } else if (slumpatTal2 == 5) {
        rad2lbl1.setLocation(273, 50);
        rad2lbl2.setLocation(273, 348);
        rad2lbl3.setLocation(273, 189);
    } else if (slumpatTal2 == 6) {
        rad2lbl1.setLocation(273, 348);
        rad2lbl2.setLocation(273, 189);
        rad2lbl3.setLocation(273, 50);

    }

    //Slumpa för Reel 3
    if (slumpatTal3 == 1) {
        rad3lbl1.setLocation(492, 50);
        rad3lbl2.setLocation(492, 187);
        rad3lbl3.setLocation(492, 348);
    } else if (slumpatTal3 == 2) {
        rad3lbl1.setLocation(492, 50);
        rad3lbl2.setLocation(492, 348);
        rad3lbl3.setLocation(492, 187);
    } else if (slumpatTal3 == 3) {
        rad3lbl1.setLocation(492, 348);
        rad3lbl2.setLocation(492, 50);
        rad3lbl3.setLocation(492, 187);
    } else if (slumpatTal3 == 4) {
        rad3lbl1.setLocation(492, 348);
        rad3lbl2.setLocation(492, 187);
        rad3lbl3.setLocation(492, 50);
    } else if (slumpatTal3 == 5) {
        rad3lbl1.setLocation(492, 187);
        rad3lbl2.setLocation(492, 50);
        rad3lbl3.setLocation(492, 348);
    } else if (slumpatTal3 == 6) {
        rad3lbl1.setLocation(492, 187);
        rad3lbl2.setLocation(492, 348);
        rad3lbl3.setLocation(492, 50);
    }

0 个答案:

没有答案