public int transactionAdded(int position, TransactionRecord transaction) {
        Date date = transaction.getDate();
        int lastElem = listData.size()-1;
        int index, lowIndex, highIndex;

        //
        // Insert the new transaction based on the transaction date (position == -1)
        // or at the specified position (position >= 0)
        //
        if (position >= 0) {
            index = position;
            listData.add(index, transaction);
        } else if (lastElem < 0) {
            index = 0;
            listData.add(transaction);
        } else if (date.compareTo(listData.get(lastElem).getDate()) >= 0) {
            index = lastElem+1;
            listData.add(transaction);
        } else {
            lowIndex = -1;
            highIndex = lastElem;
            while (highIndex-lowIndex > 1) {
                index = (highIndex-lowIndex)/2+lowIndex;
                if (date.compareTo(listData.get(index).getDate()) < 0)
                    highIndex = index;
                else
                    lowIndex = index;
            }

            index = highIndex;
            listData.add(index, transaction);
        }

        //
        // Notify table listeners
        //
        fireTableRowsInserted(index, index);
        return index;
    }