Handling fees and setting them Im trying to get the estimation of how much the fees will be when a final amount is decided on. I would say im getting familiar with bitcoinj but not completely with java so im still learning how to code and exploring how to get information.

this is my present code. I put everything inside a method.

public static String SendFund(String amount, String receiver){
        String text;
        Coin value = Coin.parseCoin(amount);
        LegacyAddress to = LegacyAddress.fromBase58(MainPage.params, receiver);
        try {
            System.out.println(gbal()+" - "+gaddress());
            Wallet.SendResult result = kit.wallet().sendCoins(kit.peerGroup(), to, value);
            text = "&lt;html&gt;"+amount+" BTC sent to address &lt;br/&gt;&lt;br/&gt;"+receiver+".&lt;/html&gt;";
            System.out.println("Check transaction : https://testnet.blockchain.info/tx/"+result.tx.getHashAsString());
        }catch(InsufficientMoneyException e){
            text = "Insufficient Funds.";
        }
        return text;
    }


Currently it doesnt deal with fees. But when i view a transaction such as this ==> https://testnet.blockchain.info/tx/194b2a7505a537307abe9443b048bc7ddce6ca0d833d5758c3be3c03a9c7b838 you can clearly see the fee.

Also when i purposely tried to send coins when i know the wallet doesnt have enough it doesnt tell me that it failed 

0.8625106 - n2uEm2QXqe2PCSsbHTdAJN9aDm2mDjz6iZ
May 02, 2018 5:08:58 PM org.bitcoinj.wallet.Wallet completeTx
INFO: Completing send tx with 1 outputs totalling 1.00 BTC and a fee of 0.001 BTC/kB


What am i doing wrong for failing to check? do i have to actually perform an if statement just to check? And also how can i calculate reliably on what the final amount would be?
I was able to resolve the issue.

public static String estFee(String amount, String receiver, WalletAppKit kit, NetworkParameters params){
        try {
            String value2 = String.format("%.8f",Double.parseDouble(amount) * MainPage.handleFee);
            //String value1 = String.format("%.8f",Double.parseDouble(amount) - Double.parseDouble(value2));
            String value1 = String.format("%.8f",Double.parseDouble(amount));
            Coin val1 = Coin.parseCoin(value1);
            //Coin val2 = Coin.parseCoin(value2);
            System.out.println(receiver);
            Address target1 = Address.fromBase58(params, receiver);
            //Address target2 = Address.fromBase58(params, MainPage.handleAddress);
            Transaction tx = new Transaction(params);
            tx.addOutput(val1, target1);
            //tx.addOutput(val2, target2);
            SendRequest req = SendRequest.forTx(tx);
            req.feePerKb = Coin.parseCoin("0.0001");
            kit.wallet().completeTx(req);
            String[] temp = req.tx.getFee().toFriendlyString().split(" ");
            return String.format("%.8f",Double.parseDouble(temp[0]));
        }catch(InsufficientMoneyException e){
            Double mis = (double)e.missing.getValue()/100000000;
            System.out.println(BackEnd.strFormat("ERROR","NSF","INFO","Not enough money. You are missing "+mis+". This was to retrieve an estimated fee."));
            return "0";
        }
    }


The library wasnt so forth coming so i had to improvise for the solution.