I created this popup window which will show up in response to a button being clicked in my gui. I have two questions regarding this.
- How do I get rid of the text field below the radio buttons?
 - I need to check which radio button was selected once the ok button is clicked but I didn't create that button. So how would I implement the actionPerformed function for that?
 
My code:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    if(evt.getSource() == jButton2)
         optionPopup();
} 
private void optionPopup(){
    JPanel panel = new JPanel();
    JRadioButton undergraduateButton = new JRadioButton();
    JRadioButton graduateButton = new JRadioButton();
    ButtonGroup group = new ButtonGroup();
    undergraduateButton.setText("Option A");
    graduateButton.setText("Option B");
    group.add(undergraduateButton);
    group.add(graduateButton);
    panel.add(undergraduateButton);
    panel.add(graduateButton);
    JOptionPane.showInputDialog(panel);

                        
Use
JOptionPane.showMessageDialoginstead ofJOptionPane.showInputDialogif you still want to have
?icon instead of!one, useyou can also remove icon by using
JOptionPane.PLAIN_MESSAGEIf you want to make sure that client pressed OK button use
If
responsewill be-1it means window was closed byXbutton, if it was0user pressedOK.More info at: https://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html
undergraduateButton.isSelected()andgraduateButton.isSelected()to see if one of them was selected.