title: Disable button if JTextFields are empty and RadioButtons are not checked
body: <p>I have a JDialog with two JTextFields, one ButtonGroup with two RadioButtons and an OK-Button. The button has to be disabled until the TextFields are filled and at least one of the RadioButtons clicked. I'm not sure how to do this.</p>
  
  <p>It works for with the JTextFields using this code:</p>
  
  <pre><code>public class Test {
    public static void main(String... args) {
      ButtonTest.show();
    }
  
  }
  
  class ButtonTest {
  
    private ButtonTest() {
      JFrame frame = new JFrame("Button Test");
      frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      frame.setLocationByPlatform(true);
  
      JPanel mainPanel = new JPanel(new GridLayout(4, 1));
  
      JTextField field1 = new JTextField(20);
      JTextField field2 = new JTextField(20);
      JLabel text = new JLabel();
      JButton printButton = new JButton("Print");
      printButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
          text.setText(field1.getText() + " - " + field2.getText());
        }
      });
      printButton.setEnabled(!field1.getText().isEmpty() &amp;&amp; !field2.getText().isEmpty());
      for (JComponent c : Arrays.asList(field1, field2, text, printButton)) {
        mainPanel.add(c);
      }
  
      setDocumentListener(field1, field2, printButton);
      setDocumentListener(field2, field1, printButton);
  
      frame.add(mainPanel);
      frame.pack();
      frame.setVisible(true);
    }
  
    private void setDocumentListener(JTextField field, JTextField other, JButton button) {
      field.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
          changed();
        }
  
        @Override
        public void insertUpdate(DocumentEvent e) {
          changed();
        }
  
        @Override
        public void changedUpdate(DocumentEvent e) {
          changed();
        }
  
        private void changed() {
          setButtonStatus(button, field.getText(), other.getText());
        }
      });
    }
  
    private void setButtonStatus(JButton button, String field1, String field2) {
      button.setEnabled(!field1.isEmpty() &amp;&amp; !field2.isEmpty());
    }
  
    public static void show() {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          new ButtonTest();
        }
      });
    }
  }
  </code></pre>
  
  <p>But what about the RadioButtons? I guess I have to somehow implement an ItemListener?</p>
  
  <p>Greetings</p>