void () { final PyRunTargetVariant targetType = getTargetType(); for (final OptionHolder optionHolder : myCustomOptions.values()) { optionHolder.setType(targetType); } Arrays.stream(myPanelForTargetFields.getComponents()).forEach(myPanelForTargetFields::remove); final GridBagConstraints cons = new GridBagConstraints(); cons.fill = GridBagConstraints.HORIZONTAL; cons.weightx = 1; if (targetType == PyRunTargetVariant.PATH) { myPanelForTargetFields.add(myPathTarget, cons); } else if (targetType == PyRunTargetVariant.PYTHON) { myPanelForTargetFields.add(myPythonTarget, cons); } }