Source:
public MountedSDCardChooserDialog(Window parentWindow, String candidatePath) { super(parentWindow, "Mounted SD Card", ModalityType.DOCUMENT_MODAL); if ( candidatePath != null && candidatePath.trim().length() != 0 ) { odkDevice = new File(candidatePath); } else { odkDevice = null; } JLabel lblChooseLocation = new JLabel("Select the mounted SD card:"); radioPanel = new JPanel(); btnOK = new JButton("OK"); btnOK.addActionListener(e -> { outcome = true; setVisible(false); }); btnCancel = new JButton("Cancel"); btnCancel.addActionListener(e -> { outcome = false; setVisible(false); }); btnRefresh = new JButton("Refresh List"); btnRefresh.addActionListener(e -> { try { btnOK.setEnabled(false); btnCancel.setEnabled(false); rebuildPanel(); } finally { btnOK.setEnabled(true); btnCancel.setEnabled(true); } }); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup() .addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addComponent(lblChooseLocation) .addComponent(radioPanel) .addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup() .addComponent(btnRefresh) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnOK) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnCancel))) .addContainerGap() ); groupLayout.setVerticalGroup(groupLayout.createSequentialGroup() .addContainerGap() .addComponent(lblChooseLocation) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(radioPanel) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) .addComponent(btnRefresh) .addComponent(btnOK) .addComponent(btnCancel)) .addContainerGap()); getContentPane().setLayout(groupLayout); rebuildPanel(); }

Target:
public MountedSDCardChooserDialog(Window parentWindow, String candidatePath) { super(parentWindow, "Mounted SD Card", ModalityType.DOCUMENT_MODAL); if ( candidatePath != null && candidatePath.trim().length() != 0 ) { odkDevice = new File(candidatePath); } else { odkDevice = null; } JLabel lblChooseLocation = new JLabel("Select the mounted SD card:"); radioPanel = new JPanel(); btnOK = new JButton("OK"); btnOK.addActionListener(__ -> { outcome = true; setVisible(false); }); btnCancel = new JButton("Cancel"); btnCancel.addActionListener(__ -> { outcome = false; setVisible(false); }); btnRefresh = new JButton("Refresh List"); btnRefresh.addActionListener(__ -> { try { btnOK.setEnabled(false); btnCancel.setEnabled(false); rebuildPanel(); } finally { btnOK.setEnabled(true); btnCancel.setEnabled(true); } }); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup() .addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addComponent(lblChooseLocation) .addComponent(radioPanel) .addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup() .addComponent(btnRefresh) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnOK) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnCancel))) .addContainerGap() ); groupLayout.setVerticalGroup(groupLayout.createSequentialGroup() .addContainerGap() .addComponent(lblChooseLocation) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(radioPanel) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) .addComponent(btnRefresh) .addComponent(btnOK) .addComponent(btnCancel)) .addContainerGap()); getContentPane().setLayout(groupLayout); rebuildPanel(); }