title: Java GUI JList application
body: <p>I am  a beginner in Java GUI. </p>
  
  <p>I am trying to build user interface with JList where the user select an item from already defined list, and a panel related to that particular item appears on the right side of the list. That is my goal. Though, what i want to achieve first is to be able to display certain panel when  certain menu item is selected of which i find it difficult due my . . .</p>
  
  <p>This is what i have done so far . . .</p>
  
  <pre><code>import java.awt.BorderLayout;
  import java.awt.Color;
  import java.awt.Font;
  
  import javax.swing.JFrame;
  import javax.swing.JList;
  import javax.swing.JPanel;
  import javax.swing.ListSelectionModel;
  
  public class MainGUI extends JFrame{
  
      JList list = new JList(
              new String[]{"Create Account","Borrow Book","Return Book",
                   "Add Book","Delete Book","Display Details"}
      );
  
      public MainGUI()
      {
          JPanel panel = new JPanel();
          JPanel panel1 = new JPanel();
          list.setForeground(Color.RED);
          list.setBackground(Color.WHITE);
          list.setSelectionForeground(Color.GREEN);
          list.setSelectionBackground(Color.LIGHT_GRAY);
          list.setFixedCellWidth(150);
          list.setFixedCellHeight(50);
          list.setFont(new Font("Serif",Font.BOLD,16));
          list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
          panel.add(list);
          add(panel,BorderLayout.WEST);
      }
  
      public static void main(String[] args) {
          MainGUI frame = new MainGUI();          
          frame.setSize(500, 350);
          frame.setLocationRelativeTo(null);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setVisible(true);
      }    
  }
  </code></pre>