Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » NumberFormat ter and zero
NumberFormat ter and zero [message #502381] Mon, 07 December 2009 22:33 Go to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Hello

i want a NumberFormatter , which can show zeros but if the textfield is empty, it shouldn't show a zero to start.
This one almost works, but it doesn't show a string which start with "0,00"
The Textfield shows ",00". how can i get the first zero?
NumberFormatter formatter = new NumberFormatter("#,###,###.##");
		formatter.setFixedLengths(false, true);


Thanks for any idea...
Re: NumberFormat ter and zero [message #502527 is a reply to message #502381] Tue, 08 December 2009 17:32 Go to previous message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
I solve it so:

public class MoneyFormatter extends NumberFormatter{
 
    public MoneyFormatter(String string) {
        super(string);
    }
 
    @Override
    protected int format(int curseur) {
        if (editValue.toString().equals(EMPTY)) {
            zeroIntLen = 0;
        } else if (editValue.toString().equals("0")) {
            zeroIntLen = 1;
        } else if (editValue.toString().equals(
                "0" + symbols.getDecimalSeparator())) {
            zeroIntLen = 1;
        } else if (editValue.toString().startsWith(
                String.valueOf(symbols.getDecimalSeparator()))) {
            zeroIntLen = 1;
        }
        return super.format(curseur);
    }
}

[Updated on: Tue, 08 December 2009 17:32]

Report message to a moderator

Previous Topic:PGroup leak problem
Next Topic:NumberFormat ter and zero
Goto Forum:
  


Current Time: Thu May 23 01:22:53 GMT 2019

Powered by FUDForum. Page generated in 0.01885 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top