import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
public class ChoiceTesti extends Applet 
{
private Choice F;
private TextField T;
public void init()
{
F=new Choice();
F.add("MonoSpaced"); // Courier
F.add("SansSerif"); // Helvetica
F.add("Serif"); // Times
T=new TextField(F.getItem(0),30);
T.setEditable(false);
T.setFont(new Font(F.getItem(0),Font.PLAIN,12));
F.addItemListener(new FontIsmiKontrolu(T));
F.addItemListener(new TextFieldKontrolu(T));
add(F);
add(T);
}
}
class FontIsmiKontrolu implements ItemListener
{
private Component C;
public FontIsmiKontrolu(Component C)
{
this.C=C;
}
public void itemStateChanged(ItemEvent e)
{
C.setFont(new Font(e.getItem().toString(),
C.getFont().getStyle(),
C.getFont().getSize()));
}
}
class TextFieldKontrolu implements ItemListener
{
private TextField T;
public TextFieldKontrolu(TextField T)
{
this.T=T;
}
public void itemStateChanged(ItemEvent e)
{
Choice C=(Choice)e.getItemSelectable();
T.setText("Indeks : "+ C.getSelectedIndex()+"; Font : "+e.getItem());
} }
