The following image pretty much illustrates the whole issue:
I have tried using // formatter:off
with the appropriate settings, but to no avail. I have also tried looking for indentation rules for lambda expressions/anonymous classes, but I couldn't find those.
Any suggestion is much appreciated!
Reformat line indents If you need to adjust indentation settings, in the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. On the appropriate language page, on the Tabs and Indents tab, specify the appropriate indents options and click OK.
By the way, you cannot always use lambda expression in place of Anonymous class, because of its limitation of being SAM type. If you are using an anonymous class to implement an interface with two abstract methods then you cannot replace it with a lambda of Java 8.
Open indentation settings in code style scheme Click the widget and select Configure Indents for 'Language'. In the dialog that opens, you can change settings for tabs and indents and also configure other code style settings. Click OK. Reformat the necessary part of your project to apply new indentation settings.
You need to close the outmost parenthesis right next to the closing bracket for the anonymous class to get the desired indentation.
Instead of:
itemClose.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
}
);
Remove the line/space between the last } and ); and you get:
itemClose.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
});
What helped for me was setting
Editor > Code Style > Java > Continuation indent
to a lower value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With