There may be a way in IB to configure the text field for the behavior you want, but you could also use a java.text.DecimalFormat, like this
DecimalFrom df = new DecimalFormat("$##,###,##0.00;$-##,###,##0.00");
System.out.println(df.format(12345.6789); // outputs "$12,345.68"
System.out.println(df.format(12345)); // outputs "$12,345"