@@ -0,0 +1,3330 @@
+/*%0A   Programmer: Kristoffer Larson%0A   Date: February 12, 2014%0A   %0A   Description: Sets up RadioButtons and prints their name%0A      when selected. Also uses setMnemonic to give access to%0A      keyboard commands in choosing a button.%0A%0A*/%0Aimport java.awt.*;%0Aimport java.awt.event.*;%0Aimport javax.swing.*;%0A %0Apublic class RadioButtons extends JPanel implements ActionListener %7B%0A   static String one = %22asdf%22;%0A   static String two = %22qwerty%22;%0A   static String three = %22erdfy%22;%0A   static String four = %22jkli%22;%0A   static String five = %22rorxo%22;%0A%0A   public RadioButtons() %7B%0A      super(new BorderLayout());%0A   %0A      //Create the radio buttons.%0A      JRadioButton aButton = new JRadioButton(one);%0A      aButton.setMnemonic(KeyEvent.VK_A);%0A      aButton.setActionCommand(one);%0A      aButton.setSelected(true);%0A   %0A      JRadioButton bButton = new JRadioButton(two);%0A      bButton.setMnemonic(KeyEvent.VK_Q);%0A      bButton.setActionCommand(two);%0A   %0A      JRadioButton cButton = new JRadioButton(three);%0A      cButton.setMnemonic(KeyEvent.VK_E);%0A      cButton.setActionCommand(three);%0A   %0A      JRadioButton dButton = new JRadioButton(four);%0A      dButton.setMnemonic(KeyEvent.VK_J);%0A      dButton.setActionCommand(four);%0A   %0A      JRadioButton eButton = new JRadioButton(five);%0A      eButton.setMnemonic(KeyEvent.VK_R);%0A      eButton.setActionCommand(five);%0A   %0A      //Group the radio buttons. Only one can be selected at a time.%0A      ButtonGroup group = new ButtonGroup();%0A      group.add(aButton);%0A      group.add(bButton);%0A      group.add(cButton);%0A      group.add(dButton);%0A      group.add(eButton);%0A    %0A      //Register a listener for the radio buttons.%0A      aButton.addActionListener(this);%0A      bButton.addActionListener(this);%0A      cButton.addActionListener(this);%0A      dButton.addActionListener(this);%0A      eButton.addActionListener(this); %0A   %0A      //Put the radio buttons in a column in a panel.%0A      JPanel radioPanel = new JPanel(new GridLayout(0, 1));%0A      radioPanel.add(aButton);%0A      radioPanel.add(bButton);%0A      radioPanel.add(cButton);%0A      radioPanel.add(dButton);%0A      radioPanel.add(eButton);%0A   %0A      add(radioPanel, BorderLayout.LINE_START);%0A      setBorder(BorderFactory.createEmptyBorder(20,20,20,20));%0A   %7D//End Constructor%0A%0A   /** Listens to the radio buttons. */%0A   public void actionPerformed(ActionEvent e) %7B%0A      System.out.printf(%22%25s%5Cn%22, e.getActionCommand());%0A   %7D//End actionPerformed%0A%0A   private static void createAndShowGUI() %7B%0A      //Create and set up the window.%0A      JFrame frame = new JFrame(%22RadioButtons%22);%0A      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);%0A   %0A      //Create and set up the content pane.%0A      JComponent newContentPane = new RadioButtons();%0A      newContentPane.setOpaque(true); //content panes must be opaque%0A      frame.setContentPane(newContentPane);%0A   %0A      //Display the window.%0A      frame.pack();%0A      frame.setVisible(true);%0A   %7D//End createAndShowGUI%0A%0A   public static void main(String%5B%5D args) %7B%0A      //Schedule a job for the event-dispatching thread:%0A      //creating and showing this application's GUI.%0A      javax.swing.SwingUtilities.invokeLater(%0A            new Runnable() %7B%0A               public void run() %7B%0A                  createAndShowGUI(); %0A               %7D//End run%0A            %7D);//End Thread%0A   %7D//End Main%0A%7D//End Class%0A

Create RadioButtons.java