home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java by Example
/
jbecd.bin
/
JBE-CD
/
NTUsers
/
JBECODE.ZIP
/
JavaByExample
/
chap20
/
TextTransferApplet.java
< prev
Wrap
Text File
|
1996-03-04
|
957b
|
46 lines
import java.awt.*;
import java.applet.*;
public class TextTransferApplet extends Applet
{
List list;
TextArea textArea;
public void init()
{
list = new List(10, false);
textArea = new TextArea("", 10, 15);
list.addItem("These");
list.addItem("are");
list.addItem("the");
list.addItem("ten");
list.addItem("words");
list.addItem("from");
list.addItem("which");
list.addItem("you");
list.addItem("can");
list.addItem("choose");
add(list);
add(textArea);
resize(300, 180);
}
public boolean action(Event evt, Object arg)
{
if (evt.target instanceof List)
TransferWord();
return true;
}
protected void TransferWord()
{
String s = list.getSelectedItem();
s += '\n';
textArea.appendText(s);
}
}