It is straightforward to turn off automatic indentation in NetBeans 14, but the process is not intuitive for Java source. These settings must be applied in sequence after navigating to the Tools > Options > Editor > Formatting screen:
Select Language: All Languages and Category: Tabs and
Indents, and then uncheck the checkbox Enable Indentation and click the Apply button. This will turn off automatic indentation for all languages by default, but that global setting might still be overridden for individual languages.
Select Language: Java and Category: Tabs and Indents, and then uncheck the checkboxes Use all Languages Settings and Enable Indentation, and click the OK button.
After making those changes the modified fields should look like this if you revisit the Tools > Options > Editor > Formatting screen:
Language: All Languages

Language: Java

Then, using your sample code, if the cursor is positioned at the end of the line containing data = Base64.getDecoder().decode(s);
and Enter is pressed:
- A new line will be inserted.
- The cursor will be positioned at the start of that new line.
This is the sample code I used:
package javaantapplication1;
import java.util.Base64;
public class JavaAntApplication1 {
private static byte[] s;
public static void main(String[] args) {
byte[] data;
try {
data = Base64.getDecoder().decode(s);
}
}
Notes:
- The steps to re-enable automatic indentation are not the reverse of those described above. Instead, simply revisit the first screen shown above, check Enable Indentation, and click OK. That is sufficient to enable indentation for Java again.
- I don't think it is possible to have automatic indentation disabled only for Java source.
- While better than nothing, the GUI for configuring indentation in NetBeans is confusing and inflexible.