void (JPanel addTo, @Nullable JLabel nameLabel) { addTo.setBorder(JBUI.Borders.emptyLeft(5)); UI.PanelFactory.panel(myPanel) .withLabel(ExecutionBundle.message("run.on")) .withComment(ExecutionBundle.message("edit.run.configuration.run.configuration.run.on.comment")) .addToPanel(addTo, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, JBInsets.emptyInsets(), 0, 0), false); JLabel runOnLabel = UIUtil.findComponentOfType(addTo, JLabel.class); if (runOnLabel != null && nameLabel != null) { runOnLabel.setLabelFor(myRunOnComboBox); Dimension nameSize = nameLabel.getPreferredSize(); Dimension runOnSize = runOnLabel.getPreferredSize(); double width = Math.max(nameSize.getWidth(), runOnSize.getWidth()); nameLabel.setPreferredSize(new Dimension((int)width, (int)nameSize.getHeight())); runOnLabel.setPreferredSize(new Dimension((int)width, (int)runOnSize.getHeight())); } myRunOnComboBox.addActionListener(e -> { String chosenTarget = myRunOnComboBox.getSelectedTargetName(); if (!StringUtil.equals(myDefaultTargetName, chosenTarget)) { setTargetName(chosenTarget); } }); }