Agustín
Agustín

Reputation: 1546

Anonymous class creation can not be evaluated. Java Design Eclipse

When I want to open the Design tab in Eclipse, I get this error: Anonymous class creation can not be evaluated.

In general case it is impossible to evaluate creation of anonymous class. So, expression ...

new AbstractFormatterFactory() { 
    @Override public AbstractFormatter getFormatter(JFormattedTextField tf) { 
        NumberFormat format = DecimalFormat.getInstance(); 
        format.setMinimumFractionDigits(2);
        format.setMaximumFractionDigits(2); 
        format.setRoundingMode(RoundingMode.HALF_UP);
        InternationalFormatter formatter = new InternationalFormatter(format); 
        formatter.setAllowsInvalid(false); 
        formatter.setMinimum(0.0);
        return formatter;
    } 
}

... was not evaluated.

The problem is in this block:

final JFormattedTextField textField1 = new JFormattedTextField(new Float(10.01));

textField1.setFormatterFactory(new AbstractFormatterFactory() {

    @Override
    public AbstractFormatter getFormatter(JFormattedTextField tf) {
        NumberFormat format = DecimalFormat.getInstance();
        format.setMinimumFractionDigits(2);
        format.setMaximumFractionDigits(2);
        format.setRoundingMode(RoundingMode.HALF_UP);
        InternationalFormatter formatter = new InternationalFormatter(format);
        formatter.setAllowsInvalid(false);
        formatter.setMinimum(0.0);
        return formatter;
    }
});

How can I solve this anonymous class thing?

Upvotes: 0

Views: 1323

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533492

What is this warning stopping you from doing other then viewing it in a Design tool?

If it is causing a concern it will be due to a random bug in the plugin.

To work out the likely cause, comment out the whole function, test it is okay not and add back the method a line at a time to see when breaks the plugin.

Upvotes: 1

Related Questions