Role of the constructor when implementing an ImageJ Command (Plugin)?

Hi,

I’m writing an imagej Command but I am a bit confused where to place the “preparation” steps. The outline of the command looks like this:

@Plugin(type = Command.class, menuPath = "Plugins>Segmentation Corrector")
public class SegmentationCorrector implements Command, KeyListener {
	
	@Parameter(label = "Label Image")
    ImagePlus labelImp; 

	final double opacity = 0.5;
	
	// more parameters here


	@Override
    public void run() {

		// preparations: create a GUI, load a LUT, ...

		// do the main plugin functionality here

	}
}

Initially I thought that these startup-preparations (like create a GUI panel, load a LUT, etc.) should be best located in a constructor. However, when adding a dummy constructor like

	public SegmentationCorrector() {
        System.out.println("Constructor called");
    }

I noticed that it is called at least three times when invoking the plugin, which was quite surprising to me.

Therefore I have two questions:

  1. Practical: Should the constructor not be used for initialization steps and everything just be placed at the beginning of the run() method? Or is there even better advice for structuring the code?

  2. Conceptual: Why was the constructor called multiple times?

Thanks already for your help!