/**********************************************************************
Virtual Cache is a program which helps to manage personal finances
Copyright (C) 2013 by Rovinskiy Nikolay
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/
package Controllers.Main;
import Messages.OKMessage;
import Utils.Card;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import java.util.Enumeration;
/**
*
* @author nrovinskiy
*/
public class TotalAmountListener implements ActionListener
{
MainWindowController mwcMain;
DecimalFormat dfCurrency;
public TotalAmountListener(MainWindowController main)
{
dfCurrency=new DecimalFormat("##0.00");
mwcMain=main;
}
public void actionPerformed(ActionEvent e) {
Enumeration<Card> enCards= mwcMain.getProfile().getCards();
double dblTotal=0;
while(enCards.hasMoreElements())
{
dblTotal+=enCards.nextElement().getBalance();
}
OKMessage okm=new OKMessage(mwcMain, "<html><body>You have <b>"+dfCurrency.format(dblTotal)+"$</b> on all your cards.</body></html>");
okm.setTitle(virtualcache.Main.ApplicationName);
okm.setVisible(true);
okm.dispose();
okm=null;
}
}