0

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?

Jason C
  • 38,729
  • 14
  • 126
  • 182
Agustín
  • 1,546
  • 7
  • 22
  • 41

1 Answers1

1

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.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • It starts when the Override begins, any ideas? – Agustín Aug 08 '13 at 16:29
  • So you are saying that `textField1.setFormatterFactory(new AbstractFormatterFactory() { @Override public AbstractFormatter getFormatter(JFormattedTextField tf) { return null; } });` breaks. What if you take out the @Override? – Peter Lawrey Aug 08 '13 at 17:02
  • if I take out the Override, it still doesn't work, I tried to comment line by line but the issue starts there. I really don't know what to do. It works fine when I run it, but I can't edit it from the Design tool – Agustín Aug 08 '13 at 17:21
  • Do you have the latest version of the design tool? – Peter Lawrey Aug 08 '13 at 17:25
  • I suggest you ask the eclipse forums as this appears to be a bug in that plugin. – Peter Lawrey Aug 08 '13 at 17:41