source code name: TextComboDemo.java
import java.awt.*;
import java.util.*;
import java.awt.event.*;
class TextComboDemo extends Frame
{
Font f1=new Font("High Tower Text",Font.BOLD,18);
TextField t1;
Choice ch;
public TextComboDemo()
{
FlowLayout fl=new FlowLayout();
setLayout(fl);
Label l1=new Label("enter OS Name ");
t1=new TextField(20);
ch=new Choice();
ch.add("windows");
Button b1=new Button("transfer");//create button
add(l1);add(t1);add(b1); //adding label , textfiled and button on frame
add(ch);
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
ch.add(t1.getText());
}
});
}
public static void main(String[] args) {
TextComboDemo f=new TextComboDemo();
f.setSize(400,500);
f.setVisible(true);
}
}
output:
0 Comments
Post a Comment