==> JTwoClassList.java <==
//Demonstratiob of simple Two-list program
//using JFC controls

import java.awt.*;
import java.awt.event.*;
//swing classes
import com.sun.java.swing.text.*;
import com.sun.java.swing.*;
import com.sun.java.swing.event.*;
import com.sun.java.swing.tree.*;
import com.sun.java.swing.border.*;


public class JTwoClassList extends JFrame
   implements ActionListener
{
   private JButton Add, MoveRight, MoveLeft;
   private JclassAwtList leftList, rightList;
   private TextField txt;

   public JTwoClassList()
   {
      super("Two Lists");
      setLF();          //set look and feel
      setCloseClick();  //Window exits on close-click
      setGUI();
   }
   //--------------------------------------------
   private void setGUI()
   {
      getContentPane().setLayout(new GridLayout(1,2));  //two columns
      setBackground(Color.lightGray);
      JPanel pLeft = new JPanel();
      JPanel pRight = new JPanel();
      getContentPane().add(pLeft);
      getContentPane().add(pRight);
      pLeft.setLayout(new BorderLayout());
      
      JPanel pTop = new JPanel();
      pLeft.add("North", pTop);
      txt = new TextField(15);
      pTop.add(txt);
      Add = new JButton("Insert");
      Add.setMargin(new Insets(0,0,0,0));

      pTop.add(Add);
      
      JPanel rBorder = new JPanel();
      rBorder.setLayout(new GridLayout(2,1));
      MoveRight = new JButton("Add --->");
      MoveLeft = new JButton("<--- Remove");
      
      JPanel rbTop = new JPanel();
      rbTop.add(MoveRight);
      rBorder.add(rbTop);
      
      JPanel rbBot = new JPanel();
      rbBot.add(MoveLeft);
      rBorder.add(rbBot);
      pLeft.add("East", rBorder);

      leftList = new JclassAwtList(15);
      JScrollPane lsp = new JScrollPane();
      pLeft.add("Center", lsp);
      lsp.getViewport().add(leftList);

      rightList = new JclassAwtList(15);
      JScrollPane rsp = new JScrollPane();
      pRight.setLayout(new BorderLayout());
      pRight.add("Center", rsp);
      rsp.getViewport().add(rightList);
      
      //Add button action listenes
      Add.addActionListener(this);
      MoveRight.addActionListener(this);
      MoveLeft.addActionListener(this);

      setSize(new Dimension(400, 300));
      setVisible(true);
   }
   //-----------------------------------------  
   private void setCloseClick()
   {
      //create window listener to respond to window close click
      addWindowListener(new WindowAdapter() 
       {
	    public void windowClosing(WindowEvent e) {System.exit(0);}
	    });
   }
   //------------------------------------------
   private void setLF()
   {
   // Force SwingApp to come up in the System L&F
	String laf = UIManager.getSystemLookAndFeelClassName();
	try {
       UIManager.setLookAndFeel(laf);
   	 }
       catch (UnsupportedLookAndFeelException exc) 
         {System.err.println("Warning: UnsupportedLookAndFeel: " + laf);}
       catch (Exception exc) {System.err.println("Error loading " + laf + ": " + exc);
	   }
   }

   //---------------------------------------------
   public void actionPerformed(ActionEvent e)
   {
      JButton b = (JButton)e.getSource();
      if(b == Add)
         addName();
      if(b == MoveRight)
         moveNameRight();
      if(b == MoveLeft)
         moveNameLeft();
   }
   //--------------------------------------------
   private void addName()
   {
      if (txt.getText().length() > 0) 
         {
         leftList.add(txt.getText());
         txt.setText("");
         }
   }
   //--------------------------------------------
   private void moveNameRight()
   {
     String sel[] = leftList.getSelectedItems();
     
     if (sel != null)        
     {
     rightList.add(sel[0]);
     leftList.remove(sel[0]);
     }
   }
   //--------------------------------------------
   public void moveNameLeft()
   {
    String sel[] = rightList.getSelectedItems();
     if (sel != null)        
     {
     leftList.add(sel[0]);
     rightList.remove(sel[0]);
     }
   }
   //--------------------------------------------
   static public void main(String argv[])
   {
      new JTwoList();
   }
}

==> JTwoList.java <==
//Demonstratiob of simple Two-list program
//using JFC controls

import java.awt.*;
import java.awt.event.*;
//swing classes
import com.sun.java.swing.text.*;
import com.sun.java.swing.*;
import com.sun.java.swing.event.*;
import com.sun.java.swing.tree.*;
import com.sun.java.swing.border.*;


public class JTwoList extends JFrame
   implements ActionListener
{
   private JButton Add, MoveRight, MoveLeft;
   private JawtList leftList, rightList;
   private TextField txt;

   public JTwoList()
   {
      super("Two Lists");
      setLF();          //set look and feel
      setCloseClick();  //Window exits on close-click
      setGUI();
   }
   //--------------------------------------------
   private void setGUI()
   {
      getContentPane().setLayout(new GridLayout(1,2));  //two columns
      setBackground(Color.lightGray);
      JPanel pLeft = new JPanel();
      JPanel pRight = new JPanel();
      getContentPane().add(pLeft);
      getContentPane().add(pRight);
      pLeft.setLayout(new BorderLayout());
      
      JPanel pTop = new JPanel();
      pLeft.add("North", pTop);
      txt = new TextField(15);
      pTop.add(txt);
      Add = new JButton("Insert");
      Add.setMargin(new Insets(0,0,0,0));

      pTop.add(Add);
      
      JPanel rBorder = new JPanel();
      rBorder.setLayout(new GridLayout(2,1));
      MoveRight = new JButton("Add --->");
      MoveLeft = new JButton("<--- Remove");
      
      JPanel rbTop = new JPanel();
      rbTop.add(MoveRight);
      rBorder.add(rbTop);
      
      JPanel rbBot = new JPanel();
      rbBot.add(MoveLeft);
      rBorder.add(rbBot);
      pLeft.add("East", rBorder);

      leftList = new JawtList(15);
      pLeft.add("Center", leftList);

      rightList = new JawtList(15);
      pRight.setLayout(new BorderLayout());
      pRight.add("Center", rightList);
      
      //Add button action listenes
      Add.addActionListener(this);
      MoveRight.addActionListener(this);
      MoveLeft.addActionListener(this);

      setSize(new Dimension(400, 300));
      setVisible(true);
   }
   //-----------------------------------------  
   private void setCloseClick()
   {
      //create window listener to respond to window close click
      addWindowListener(new WindowAdapter() 
       {
	    public void windowClosing(WindowEvent e) {System.exit(0);}
	    });
   }
   //------------------------------------------
   private void setLF()
   {
   // Force SwingApp to come up in the System L&F
	String laf = UIManager.getSystemLookAndFeelClassName();
	try {
       UIManager.setLookAndFeel(laf);
   	 }
       catch (UnsupportedLookAndFeelException exc) 
         {System.err.println("Warning: UnsupportedLookAndFeel: " + laf);}
       catch (Exception exc) {System.err.println("Error loading " + laf + ": " + exc);
	   }
   }

   //---------------------------------------------
   public void actionPerformed(ActionEvent e)
   {
      JButton b = (JButton)e.getSource();
      if(b == Add)
         addName();
      if(b == MoveRight)
         moveNameRight();
      if(b == MoveLeft)
         moveNameLeft();
   }
   //--------------------------------------------
   private void addName()
   {
      if (txt.getText().length() > 0) 
         {
         leftList.add(txt.getText());
         txt.setText("");
         }
   }
   //--------------------------------------------
   private void moveNameRight()
   {
     String sel[] = leftList.getSelectedItems();
     
     if (sel != null)        
     {
     rightList.add(sel[0]);
     leftList.remove(sel[0]);
     }
   }
   //--------------------------------------------
   public void moveNameLeft()
   {
    String sel[] = rightList.getSelectedItems();
     if (sel != null)        
     {
     leftList.add(sel[0]);
     rightList.remove(sel[0]);
     }
   }
   //--------------------------------------------
   static public void main(String argv[])
   {
      new JTwoList();
   }
}

==> JawtList.java <==
import java.awt.*;
import java.awt.event.*;
import java.util.*;
//swing classes
import com.sun.java.swing.text.*;
import com.sun.java.swing.*;
import com.sun.java.swing.event.*;
import com.sun.java.swing.tree.*;
import com.sun.java.swing.border.*;

//this is a simple adapter class to
//convert List awt methods to Swing methods

public class JawtList extends JScrollPane 
   implements ListSelectionListener, awtList
{
   private JList listWindow;
   private JListData listContents;
//-----------------------------------------
   public JawtList(int rows)
   {
      listContents = new JListData();
      listWindow = new JList(listContents);
      listWindow.setPrototypeCellValue("Abcdefg Hijkmnop");
      getViewport().add(listWindow);
      
   }
//-----------------------------------------
   public void add(String s)
   {
      listContents.addElement(s);
   }
//-----------------------------------------
   public void remove(String s)
   {
      listContents.removeElement(s);
   }
//-----------------------------------------
   public String[] getSelectedItems()
   {
      Object[] obj = listWindow.getSelectedValues();
      String[] s = new String[obj.length];
      for (int i =0; i<obj.length; i++) 
            s[i] = obj[i].toString();
      return s;
   }
//-----------------------------------------
   public void valueChanged(ListSelectionEvent e)
   {
   }
   
}
//  =========================================
class JListData extends AbstractListModel
{
   private Vector data;
//-----------------------------------------
   public JListData()
   {
      data = new Vector();
   }
//-----------------------------------------
   public int getSize()
   {
      return data.size();
   }
//-----------------------------------------
   public Object getElementAt(int index)
   {
      return data.elementAt(index);
   }
//-----------------------------------------
   public void addElement(String s)
   {
      data.addElement(s);
      fireIntervalAdded(this, data.size()-1, data.size());
   }
//-----------------------------------------
   public void removeElement(String s)
   {
      data.removeElement(s);
      fireIntervalRemoved(this, 0, data.size());
   }
}

==> JclassAwtList.java <==
import java.awt.*;
import java.awt.event.*;
import java.util.*;
//swing classes
import com.sun.java.swing.text.*;
import com.sun.java.swing.*;
import com.sun.java.swing.event.*;
import com.sun.java.swing.tree.*;
import com.sun.java.swing.border.*;

//this is a simple adapter class to
//convert List awt methods to Swing methods

public class JclassAwtList extends JList
   implements ListSelectionListener, awtList
{
   private JListData listContents;
//-----------------------------------------
   public JclassAwtList(int rows)
   {
      listContents = new JListData();
      setModel(listContents);
      setPrototypeCellValue("Abcdefg Hijkmnop");     
   }
//-----------------------------------------
   public void add(String s)
   {
      listContents.addElement(s);
   }
//-----------------------------------------
   public void remove(String s)
   {
      listContents.removeElement(s);
   }
//-----------------------------------------
   public String[] getSelectedItems()
   {
      Object[] obj = getSelectedValues();
      String[] s = new String[obj.length];
      for (int i =0; i<obj.length; i++) 
            s[i] = obj[i].toString();
      return s;
   }
//-----------------------------------------
   public void valueChanged(ListSelectionEvent e)
   {
   }
   
}
//  =========================================
class JListData extends AbstractListModel
{
   private Vector data;
//-----------------------------------------
   public JListData()
   {
      data = new Vector();
   }
//-----------------------------------------
   public int getSize()
   {
      return data.size();
   }
//-----------------------------------------
   public Object getElementAt(int index)
   {
      return data.elementAt(index);
   }
//-----------------------------------------
   public void addElement(String s)
   {
      data.addElement(s);
      fireIntervalAdded(this, data.size()-1, data.size());
   }
//-----------------------------------------
   public void removeElement(String s)
   {
      data.removeElement(s);
      fireIntervalRemoved(this, 0, data.size());
   }
}

==> TwoList.java <==
//Demonstratio of simple Two-list program
//using awt controls

import java.awt.*;
import java.awt.event.*;

public class TwoList extends Frame
   implements ActionListener
{
   private Button Add, MoveRight, MoveLeft;
   private List leftList, rightList;
   private TextField txt;

   public TwoList()
   {
      super("Two Lists");
      setCloseClick();
      setGUI();
   }
   //--------------------------------------------
   private void setGUI()
   {
      setLayout(new GridLayout(1,2));  //two columns
      setBackground(Color.lightGray);
      Panel pLeft = new Panel();
      Panel pRight = new Panel();
      add(pLeft);
      add(pRight);
      pLeft.setLayout(new BorderLayout());
      
      //top panel contains text field and 
      //Insert buttn
      Panel pTop = new Panel();
      pLeft.add("North", pTop);
      txt = new TextField(10);
      pTop.add(txt);
      Add = new Button("Insert");
      pTop.add(Add);
      
      //right border contains add and remove buttons
      Panel rBorder = new Panel();
      rBorder.setLayout(new GridLayout(2,1));
      MoveRight = new Button("Add --->");
      MoveLeft = new Button("<--- Remove");
      
      Panel rbTop = new Panel();
      rbTop.add(MoveRight);
      rBorder.add(rbTop);
      
      Panel rbBot = new Panel();
      rbBot.add(MoveLeft);
      rBorder.add(rbBot);
      pLeft.add("East", rBorder);

      leftList = new List(10);
      pLeft.add("Center", leftList);

      rightList = new List(10);
      pRight.add(rightList);

      //Add button action listenes
      Add.addActionListener(this);
      MoveRight.addActionListener(this);
      MoveLeft.addActionListener(this);

      setSize(new Dimension(400, 300));
      setVisible(true);
   }
   //-----------------------------------------  
   private void setCloseClick()
   {
      //create window listener to respond to window close click
      addWindowListener(new WindowAdapter() 
       {
	    public void windowClosing(WindowEvent e) {System.exit(0);}
	    });
   }
   //---------------------------------------------
   public void actionPerformed(ActionEvent e)
   {
      Button b = (Button)e.getSource();
      if(b == Add)
         addName();
      if(b == MoveRight)
         moveNameRight();
      if(b == MoveLeft)
         moveNameLeft();
   }
   //--------------------------------------------
   private void addName()
   {
      if (txt.getText().length() > 0) 
         {
         leftList.add(txt.getText());
         txt.setText("");
         }
   }
   //--------------------------------------------
   private void moveNameRight()
   {
     String sel[] = leftList.getSelectedItems();
     if (sel != null)        
     {
     rightList.add(sel[0]);
     leftList.remove(sel[0]);
     }
   }
   //--------------------------------------------
   public void moveNameLeft()
   {
    String sel[] = rightList.getSelectedItems();
     if (sel != null)        
     {
     leftList.add(sel[0]);
     rightList.remove(sel[0]);
     }
   }
   //--------------------------------------------
   static public void main(String argv[])
   {
      new TwoList();
   }
}

==> awtList.java <==
public interface awtList
{
     public void add(String s);
     public void remove(String s);
     public String[] getSelectedItems();

}

==> showMethods.java <==
import java.lang.reflect.*;
import com.sun.java.swing.*;


public class showMethods
{
   public showMethods()
   {
      JList list = new JList();
      Method[] methods = list.getClass().getMethods();
      for (int i = 0; i < methods.length; i++)
      {
         System.out.println(methods[i].getName());
         Class cl[] = methods[i].getParameterTypes();
         for(int j=0; j < cl.length; j++)
            System.out.println(cl[j].toString());
      }
   }
   static public void main(String argv[])
   {
      new showMethods();
   }
}

