Hello. I'm new to Java. I created 4 CHOICE that has 9 numbers. It should convert the selected item into words in the text area. I don't have any idea how to do it. Please Help. Here's my code.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Final1 extends Frame implements ItemListener{
Final1(){
super("Choice and Text Area");
for (int i=0; i<10; i++) {
c1.addItem(" "+i);
c2.addItem(" "+i);
c3.addItem(" "+i);
c4.addItem(" "+i);
}
Panel p1=new Panel();
p1.setLayout(new FlowLayout());
p1.add(c1);
p1.add(c2);
p1.add(c3);
p1.add(c4);
Panel p2=new Panel();
p2.setLayout(new GridLayout(2,2));
p2.add(p1);
p2.add(ta1);
setLayout(new BorderLayout());
add("North",p2);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
c4.addItemListener(this);
}
public void itemStateChanged(ItemEvent arg0) {
}
public static void main(String args[]){
Final1 frame=new Final1();
frame.setSize(300,150);
frame.addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{ System.exit(0);}});
frame.setLocation(251,226);
frame.setResizable(false);
frame.show();
}
}
Inline Code Example Here`