gt:             JFileChooser fc = new JFileChooser();
context: /******************************************************************************
   * Product: Adempiere ERP & CRM Smart Business Solution                       *
   * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.                *
   * This program is free software; you can redistribute it and/or modify it    *
   * under the terms version 2 of the GNU General Public License as published   *
   * by the Free Software Foundation. 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, write to the Free Software Foundation, Inc.,    *
   * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
   * For the text or an alternative of this public license, you may reach us    *
   * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA        *
   * or via info@compiere.org or http://www.compiere.org/license.html           *
   *****************************************************************************/
  package org.eevolution.form;
  
  import org.compiere.apps.ADialog;
  import org.compiere.apps.ConfirmPanel;
  import org.compiere.apps.form.FormFrame;
  import org.compiere.apps.form.FormPanel;
  import org.compiere.grid.ed.VNumber;
  import org.compiere.plaf.CompiereColor;
  import org.compiere.print.ReportCtl;
  import org.compiere.print.ReportEngine;
  import org.compiere.swing.CComboBox;
  import org.compiere.swing.CLabel;
  import org.compiere.swing.CPanel;
  import org.compiere.util.DB;
  import org.compiere.util.DisplayType;
  import org.compiere.util.Env;
  import org.compiere.util.Ini;
  import org.compiere.util.KeyNamePair;
  import org.compiere.util.Msg;
  import org.compiere.util.ValueNamePair;
  import org.eevolution.model.MHRPaySelectionCheck;
  import org.eevolution.util.HRPaymentExport;
  
  import javax.swing.JButton;
  import javax.swing.JFileChooser;
  import java.awt.BorderLayout;
  import java.awt.Cursor;
  import java.awt.FlowLayout;
  import java.awt.GridBagConstraints;
  import java.awt.GridBagLayout;
  import java.awt.Insets;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.util.ArrayList;
  import java.util.logging.Level;
  
  /**
   *  Payment Print & Export
   *
   * 	@author 	Jorg Janke
   * 	@version 	$Id: VPayPrint.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
   */
  public class VHRPayPrint extends HRPayPrint implements FormPanel, ActionListener
  {
  	private CPanel panel = new CPanel();
  
  	/**
  	 *	Initialize Panel
  	 *  @param WindowNo window
  	 *  @param frame frame
  	 */
  	public void init (int WindowNo, FormFrame frame)
  	{
  		log.info("");
  		m_WindowNo = WindowNo;
  		m_frame = frame;
  		try
  		{
  			jbInit();
  			dynInit();
  			frame.getContentPane().add(centerPanel, BorderLayout.CENTER);
  			frame.getContentPane().add(southPanel, BorderLayout.SOUTH);
  		}
  		catch(Exception e)
  		{
  			log.log(Level.SEVERE, "", e);
  		}
  	}	//	init
  
  	
  	/**	FormFrame			*/
  	private FormFrame m_frame;
  	
  	//  Static Variables
  	private CPanel centerPanel = new CPanel();
  	private CPanel southPanel = new CPanel();
  	private FlowLayout southLayout = new FlowLayout();
  	private GridBagLayout centerLayout = new GridBagLayout();
  	private JButton bPrint = ConfirmPanel.createPrintButton(true);
  	private JButton bExport = ConfirmPanel.createExportButton(true);
  	private JButton bCancel = ConfirmPanel.createCancelButton(true);
  	private JButton bProcess = ConfirmPanel.createProcessButton(Msg.getMsg(Env.getCtx(), "VHRPayPrintProcess"));
  	private CLabel lPaySelect = new CLabel();
  	private CComboBox fPaySelect = new CComboBox();
  	private CLabel lBank = new CLabel();
  	private CLabel fBank = new CLabel();
  	private CLabel lPaymentRule = new CLabel();
  	private CComboBox fPaymentRule = new CComboBox();
  	private CLabel lDocumentNo = new CLabel();
  	private VNumber fDocumentNo = new VNumber();
  	private CLabel lNoPayments = new CLabel();
  	private CLabel fNoPayments = new CLabel();
  	private CLabel lBalance = new CLabel();
  	private VNumber fBalance = new VNumber();
  	private CLabel lCurrency = new CLabel();
  	private CLabel fCurrency = new CLabel();
  
  	/**
  	 *  Static Init
  	 *  @throws Exception
  	 */
  	private void jbInit() throws Exception
  	{
  		CompiereColor.setBackground(panel);
  		//
  		southPanel.setLayout(southLayout);
  		southLayout.setAlignment(FlowLayout.RIGHT);
  		centerPanel.setLayout(centerLayout);
  		//
  		bPrint.addActionListener(this);
  		bExport.addActionListener(this);
  		bCancel.addActionListener(this);
  		//
  		bProcess.setText(Msg.getMsg(Env.getCtx(), "EFT"));
  		bProcess.setEnabled(false);
  		bProcess.addActionListener(this);
  		//
  		lPaySelect.setText(Msg.translate(Env.getCtx(), "HR_PaySelection_ID"));
  		fPaySelect.addActionListener(this);
  		//
  		lBank.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
  		//
  		lPaymentRule.setText(Msg.translate(Env.getCtx(), "PaymentRule"));
  		fPaymentRule.addActionListener(this);
  		//
  		lDocumentNo.setText(Msg.translate(Env.getCtx(), "DocumentNo"));
  		fDocumentNo.setDisplayType(DisplayType.Integer);
  		lNoPayments.setText(Msg.getMsg(Env.getCtx(), "NoOfPayments"));
  		fNoPayments.setText("0");
  		lBalance.setText(Msg.translate(Env.getCtx(), "CurrentBalance"));
  		fBalance.setReadWrite(false);
  		fBalance.setDisplayType(DisplayType.Amount);
  		lCurrency.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
  		//
  		southPanel.add(bCancel, null);
  		southPanel.add(bExport, null);
  		southPanel.add(bPrint, null);
  		southPanel.add(bProcess, null);
  		//
  		centerPanel.add(lPaySelect,  new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
  			, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0));
  		centerPanel.add(fPaySelect,    new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
  			, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0));
  		centerPanel.add(lBank,   new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
  			, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
  		centerPanel.add(fBank,    new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
  			, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0));
  		centerPanel.add(lPaymentRule,   new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
  			, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
  		centerPanel.add(fPaymentRule,    new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
  			, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0));
  		centerPanel.add(lDocumentNo,   new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
  			, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
  		centerPanel.add(fDocumentNo,    new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
  			, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0));
  		centerPanel.add(lNoPayments,   new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0
  			, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
  		centerPanel.add(fNoPayments,    new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0
  			, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0));
  		centerPanel.add(lBalance,    new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0
  			, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
  		centerPanel.add(fBalance,    new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0
  			, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0));
  		centerPanel.add(lCurrency,  new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
  			, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 12, 5), 0, 0));
  		centerPanel.add(fCurrency,   new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
  			, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 12, 12), 0, 0));
  	}   //  VPayPrint
  
  	/**
  	 *  Dynamic Init
  	 */
  	private void dynInit()
  	{
  		ArrayList<KeyNamePair> data = getPaySelectionData();
  		for(KeyNamePair pp : data)
  			fPaySelect.addItem(pp);
  		
  		if (fPaySelect.getItemCount() == 0)
  			ADialog.info(m_WindowNo, panel, "VPayPrintNoRecords");
  		else
  		{
  			fPaySelect.setSelectedIndex(0);
  			loadPaySelectInfo();
  		}
  	}   //  dynInit
  
  	/**
  	 * 	Dispose
  	 */
  	public void dispose()
  	{
  		if (m_frame != null)
  			m_frame.dispose();
  		m_frame = null;
  	}	//	dispose
  
  	/**
  	 * 	Set Payment Selection
  	 *	@param HR_PaySelection_ID id
  	 */
  	public void setPaySelection (int HR_PaySelection_ID)
  	{
  		if (HR_PaySelection_ID == 0)
  			return;
  		//
  		for (int i = 0; i < fPaySelect.getItemCount(); i++)
  		{
  			KeyNamePair pp = (KeyNamePair)fPaySelect.getItemAt(i);
  			if (pp.getKey() == HR_PaySelection_ID)
  			{
  				fPaySelect.setSelectedIndex(i);
  				return;
  			}
  		}
  	}	//	setsetPaySelection
  
  	
  	/**************************************************************************
  	 *  Action Listener
  	 *  @param e event
  	 */
  	public void actionPerformed(ActionEvent e)
  	{
  	//	log.config( "VPayPrint.actionPerformed" + e.toString());
  		if (e.getSource() == fPaySelect)
  			loadPaySelectInfo();
  		else if (e.getSource() == fPaymentRule)
  			loadPaymentRuleInfo();
  		//
  		else if (e.getSource() == bCancel)
  			dispose();
  		else if (e.getSource() == bExport)
  			cmd_export();
  		else if (e.getSource() == bProcess)
  			cmd_EFT();
  		else if (e.getSource() == bPrint)
  			cmd_print();
  	}   //  actionPerformed
  
  	/**
  	 *  PaySelect changed - load Bank
  	 */
  	private void loadPaySelectInfo()
  	{
  		log.info( "VPayPrint.loadPaySelectInfo");
  		if (fPaySelect.getSelectedIndex() == -1)
  			return;
  		
  		int C_PaySelection_ID = ((KeyNamePair)fPaySelect.getSelectedItem()).getKey();
  		loadPaySelectInfo(C_PaySelection_ID);
  		
  		fBank.setText(bank);
  		fCurrency.setText(currency);
  		fBalance.setValue(balance);
  		
  		loadPaymentRule();
  	}   //  loadPaySelectInfo
  
  	/**
  	 *  Bank changed - load PaymentRule
  	 */
  	private void loadPaymentRule()
  	{
  		log.info("");
  		if (m_C_BankAccount_ID == -1)
  			return;
  		
  		fPaymentRule.removeAllItems();
  		
  		int C_PaySelection_ID = ((KeyNamePair)fPaySelect.getSelectedItem()).getKey();
  		ArrayList<ValueNamePair> data = loadPaymentRule(C_PaySelection_ID);
  		for(ValueNamePair pp : data)
  			fPaymentRule.addItem(pp);
  		
  		if (fPaymentRule.getItemCount() > 0)
  			fPaymentRule.setSelectedIndex(0);
  		
  		loadPaymentRuleInfo();
  	}   //  loadPaymentRule
  
  	/**
  	 *  PaymentRule changed - load DocumentNo, NoPayments,
  	 *  enable/disable EFT, Print
  	 */
  	private void loadPaymentRuleInfo()
  	{
  		ValueNamePair pp = (ValueNamePair)fPaymentRule.getSelectedItem();
  		if (pp == null)
  			return;
  		String PaymentRule = pp.getValue();
  
  		log.info("PaymentRule=" + PaymentRule);
  		fNoPayments.setText(" ");
  		
  		int C_PaySelection_ID = ((KeyNamePair)fPaySelect.getSelectedItem()).getKey();
  		String msg = loadPaymentRuleInfo(C_PaySelection_ID, PaymentRule);
  		
  		if(noPayments != null)
  			fNoPayments.setText(noPayments);
  		
  		bProcess.setEnabled(PaymentRule.equals("T"));
  		
  		if(documentNo != null)
  			fDocumentNo.setValue(documentNo);
  		
  		if(msg != null && msg.length() > 0)
  			ADialog.error(m_WindowNo, panel, msg);
  	}   //  loadPaymentRuleInfo
  
      /**************************************************************************
       *  Export payments to file
       */
      private void cmd_export()
      {
          String PaymentRule = ((ValueNamePair)fPaymentRule.getSelectedItem()).getValue();
          log.info(PaymentRule);
          if (!getChecks(PaymentRule))
              return;
  
  
          try
          {
  