Share with others

Developing Applet To edit text

 

import java.awt.*;
import java.applet.Applet;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class ffinal extends Applet implements ItemListener
{
TextArea text;
Checkbox cbold,citalic;
Choice fname,fsize;
public void init()
{
text=new TextArea(“Sample Text”);
cbold=new Checkbox(“bold”);

citalic=new Checkbox(“italic”);
fname=new Choice();
fsize=new Choice();
fname.add(“Monospaced”);
fname.add(“Arial”);
fname.add(“Serif”);
fname.add(“courier”);
fsize.add(“10”);
fsize.add(“15”);
fsize.add(“20”);
fsize.add(“25”);
fsize.add(“30”);
fsize.add(“60”);
add(text);
add(cbold);
add(citalic);
add(fsize);
add(fname);
cbold.addItemListener(this);
citalic.addItemListener(this);
fsize.addItemListener(this);
fname.addItemListener(this);
}
public void itemStateChanged(ItemEvent itemevent)
{
int var=0;
if(cbold.getState())
var=1;
if(citalic.getState())
var=2;
if(cbold.getState()&&citalic.getState())
var=3;
text.setFont(new Font(fname.getSelectedItem(),var,Integer.parseInt(fsize.getSelectedItem())));
}
}

Download File


Share with others