2014-12-07 75 views
-1

我的總收入不會出現。我計算了所有不同的扣減項,並且所有按鈕都起作用,並出現值。但是對於計算淨收入的最終按鈕,這些值不會出現。當我運行它時,我沒有得到任何值。顯示總淨收入,雙倍值不會出現

我怎樣才能得到PRSI,稅收抵免,在每個動作監聽器的最終值,並將其用於我的最終按鈕,這是計算淨收入。

繼承人我的完整代碼它是不會工作的淨按鈕。

我只是想讓淨收入出現在最後。

// Net income 
    net.addActionListener(new ActionListener() { 
     public void actionPerformed(ActionEvent en) { 
     String line = ""; 
      double grossENt = Double.parseDouble(gross.getText()); 

      netin = grossENt -((totalTax+ PRSI + uscTotal) - allcredit); 

     line = line +" Net income" + netin; 
     } 
    }); 
+4

你能分享你的代碼哪些不起作用嗎? – 2014-12-07 13:31:40

+0

重新編輯 - 您錯過了很多代碼。所以你已經把一些東西放在'line'裏了......你用它做了什麼? – 2014-12-07 13:37:58

+0

ive添加了我所有的代碼] – 2014-12-07 13:44:57

回答

0

你的根本問題是,你填充一個局部變量line,但從來沒有使用它的任何東西:

// Net income 
net.addActionListener(new ActionListener() { 
    public void actionPerformed(ActionEvent en) { 
    String line = "";      // <=============== It's a local 
     double grossENt = Double.parseDouble(gross.getText()); 

     netin = grossENt -((totalTax+ PRSI + uscTotal) - allcredit); 

    line = line +" Net income" + netin; // <================ You never do anything with it 
    } 
}); 

在你的代碼中的其他聽衆,你有這個地方line變量,一般結束收聽者:

statementTextArea.append(line); 

也許你想在上面這樣做。

+1

非常感謝你在這裏坐了一個小時,試圖找出答案。沒有看到。 – 2014-12-07 13:47:51