title: Marshal save menu item of jlist to XML and unmarshal load menu items
body: <p>I have been doing research on here and have been searching for a solution to the problem. I am new to java so I don't know all of the syntax. I am trying to get my code to transfer items from create methods for the save and load menu items.  The save event handler should call a method save() and save the list of parts in the right panel to an XML file.  The load event handler should call a method load() and it should display the unmarshalled data in the right panel. I am not familiar with JAXB or XML whatsoever.  I have tried to see if anyone else has done something similar but I cannot complete the code. Can anyone help me out please? Below is the entire code.  I have found the solution to make it exit using event handlers, but I am stuck on marshalling and unmarshalling the save and load menu items.</p>
  
  <pre><code>import java.awt.BorderLayout;
  import java.awt.EventQueue;
  import java.awt.event.ActionEvent;
  import javax.swing.DefaultListModel;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JList;
  import javax.swing.JMenu;
  import javax.swing.JMenuBar;
  import javax.swing.JMenuItem;
  import javax.swing.JPanel;
  
  public class Window {
  
  private final JFrame frame;
  
  public static void main(String[] args) {
      EventQueue.invokeLater(() -&gt; {
          Window window = new Window();
          window.frame.setVisible(true);
  
      });
  }
  
  public Window() {
      frame = new JFrame();
      frame.setBounds(100, 100, 450, 300);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.getContentPane().setLayout(null);
  
      initialize();
  }
  
  public void initialize() {
      //Creating the Panel for Menu Bar       
      JPanel panel = new JPanel();
      panel.setBounds(0, 0, 434, 23);
      frame.getContentPane().add(panel);
      panel.setLayout(new BorderLayout(0, 0));
      //Creating the Menu File Bar
      JMenuBar bar = new JMenuBar();
      panel.add(bar, BorderLayout.NORTH);
      JMenu file = new JMenu("File");
      JMenuItem load = new JMenuItem("Load");
      JMenuItem save = new JMenuItem("Save");
      JMenuItem exit = new JMenuItem("Exit");
      file.add(load);
      load.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent event) {
  
  
      }
      });
      file.add(save);
      save.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent event) {
  
  
      }
      });
      file.add(exit);
      exit.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent event) {
              System.exit(0);
      }
      });
      bar.add(file);
  
      //Populate Left List with part names    
      final DefaultListModel parts = new DefaultListModel();
      parts.addElement("Case");
      parts.addElement("Motherboard");
      parts.addElement("CPU");
      parts.addElement("GPU");
      parts.addElement("PSU");
      parts.addElement("RAM");
      parts.addElement("HDD");
  
      final JList leftList = new JList(parts);
      leftList.setBounds(10, 26, 142, 224);
      frame.getContentPane().add(leftList);
  
      //create right list 
      final DefaultListModel partSelected = new DefaultListModel();
      final JList rightList = new JList(partSelected);
      rightList.setBounds(282, 26, 142, 224);
      frame.getContentPane().add(rightList);
  
      //add event to the button to move items from left list to right list
      JButton btnNewButton = new JButton("&gt;&gt;");
      btnNewButton.addActionListener((ActionEvent arg0) -&gt; {
          for (Object selectedValue : leftList.getSelectedValuesList()) {
              partSelected.addElement(selectedValue);
              parts.removeElement(selectedValue);
              int iSelected = leftList.getSelectedIndex();
              if (iSelected == -1) {
                  return;
              }
          }
      });
      btnNewButton.setBounds(172, 86, 89, 23);
      frame.getContentPane().add(btnNewButton);
  
      //Remove Button     
      JButton remove = new JButton("&lt;&lt;");
      remove.addActionListener((ActionEvent arg0) -&gt; {
          for (Object selectedValue : rightList.getSelectedValuesList()) {
              parts.addElement(selectedValue);
              partSelected.removeElement(selectedValue);
              int selected = rightList.getSelectedIndex();
              if (selected == -1) {
                  return;
              }
          }
      });
      remove.setBounds(172, 140, 89, 23);
      frame.getContentPane().add(remove);
  }
  }
  </code></pre>