import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class JListTestiSWF extends JFrame implements ListSelectionListener
{
private JList F;
private JTextField T;

public JListTestiSWF()
{
super("JList ve JScrollPane örneği");
Container co=getContentPane();
String Liste[]={"MonoSpaced","SansSerif","Serif"};
F=new JList(Liste);
F.setVisibleRowCount(2);
F.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
F.setSelectedIndex(0);
T=new JTextField((String)F.getSelectedValue());
T.setEditable(false);
T.setFont(new Font((String)F.getSelectedValue(),Font.BOLD,12));
F.addListSelectionListener(this);
JScrollPane sp=new JScrollPane(F);
co.add(sp,BorderLayout.NORTH);
co.add(T,BorderLayout.CENTER);
}

public void valueChanged(ListSelectionEvent e)
{
T.setFont(new Font((String)F.getSelectedValue(),
T.getFont().getStyle(),
T.getFont().getSize()));
T.setText("Indeks : "+ F.getSelectedIndex()+"    Font : "+F.getSelectedValue());
}

 

      public static void main(String[] args)
      {
      JListTestiSWF pencere= new JListTestiSWF();

      pencere.addWindowListener(new BasicWindowMonitor());

      pencere.setSize(300,200);

      pencere.setVisible(true);

      }
}

