带标签的非法转发参考

时间:2015-08-10 12:53:44

标签: java netbeans jlabel

我遇到这个问题......

与上一篇文章不同,我用Google搜索,没有任何帮助。

为什么我在这里得到:非法前向引用错误,以及如何修复它?

actionMessage

错误全部来自标签

编辑左边这个

   public class guihanging extends javax.swing.JFrame {

 int re;
 String [] A = new String[10];
 String word;
 String dash = "";
 int picture = 2;
 String letter = "qw";
 int startOver;
 int qq=0;
 int ww=0;
 int ee=0;
 int rr=0;
 int tt=0;
 int yy=0;
 int uu=0;
 int ii=0;
 int oo=0;
 int pp=0;
 int aa=0;
 int ss=0; 
 int dd=0;
 int ff=0;
 int gg=0;
 int hh=0;
 int jj=0;
 int kk=0;
 int ll=0;
 int zz=0;
 int xx=0;
 int cc=0;
 int vv=0;
 int bb=0;
 int nn=0;
 int mm=0;




public guihanging() {
    initComponents();

    { 
       A[0]="rob";
       A[1]= "welcome";
       A[2]= "carbohydrates";
       A[3]= "resiprocity"; 
       A[4]="fatty";
       A[5]="baggy";
       A[6]="laptop";
       A[7]="personalcomputer";
       A[8]="monitor";
       A[9]="mouse";
     }
}
public void letters()
{System.out.println("");}
{
 int wordleng = word.length();
    for (int i2 = 0; i2 < wordleng; i2++) 
    {

      int position = word.indexOf(letter);
      if (position >= 0)
      {
         String before = word.substring(0,position);
         String after = word.substring(position+1);
         word = before + "@" + after; 
         int dashPosition = position * 2;
         String dashBefore = dash.substring(0,dashPosition);
         String dashAfter = dash.substring(dashPosition + 1);
         dash = dashBefore + letter + dashAfter;
         lblWord.setText(dash);//error

      }
      else 
      {
         lblPicture.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pictures/"+picture+".png")));// error
         picture++;
         if (picture == 7)
         {
             JOptionPane.showConfirmDialog(rootPane, "Unluck, You just did a burpee!!"+"/n"+"do you want to start again?");

             if (true)
             {
               re = (int) (Math.random ()*10);
               word = "aaabcqdefghiqjklmnopqrstuvwxyz"; //A[re];
               for (int i1 = 0; wordleng < 10; i1++) 
                  {
                     dash = dash + "_ ";
                  }
              lblWord.setText(dash);/error
            }

         }
      }

    }
}    

1 个答案:

答案 0 :(得分:0)

“非法转发引用”表示您使用未定义的变量。也许您错过了定义变量:dashlblWord