in this pgm, 1 textbox and 1 button displays in the frame. if i enter 3 in the text box means, three buttons will display on right hand side. Then if click every single button means it should display two butons on lefthand side. plz help me.
The code is as follows.
import java.awt.*;
import java.awt.event.*;
public class buttons1 extends Frame implements ActionListener
{
TextField t1;
Button b1,b2,b3;
Button[] bu;
Button[] bt;
Button BB;
int x1=700;
int y1=0;
int x2=100;
int y2=10;
int x3=180;
int y3=10;
int s1;
int s3;
String s;
public buttons1()
{
setLayout(null);
t1=new TextField(20);
b1=new Button("Enter");
add(b1);
add(t1);
b1.addActionListener(this);
b1.setBackground(Color.blue);
t1.setBounds(400,100,70,30);
b1.setBounds(400,300,70,30);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
s=t1.getText();
s1=Integer.parseInt(s);
System.out.println("Value of I is"+s1);
String s2[]={"Rone","Rtwo","Rthree","Rfour","Rfive","Rsix","R seven","Reight","Rnine","Rten","Releven","Rtwelve" ,"Rthirteen","Rfourteen","Rfifteen"};
for(int i=0;i<s1;i++)
{
Graphics g=getGraphics();
int y;
y=600/s1;
bu=new Button[s1];
bu[i]=new Button(s2[i]);
bu[i].addActionListener(this);
add(bu[i]);
y1=y1+y;
bu[i].setBounds(x1,y1,70,30);
g.drawLine(470,310,x1,y1+20);
bu[i].setBackground(Color.red);
}
}
s=t1.getText();
s1=Integer.parseInt(s);
for(int i=0;i<s1;s1++)
{
System.out.println(i);
//bu[i].addActionListener(this);
if(ae.getSource()==bu[i])
{
System.out.println("Value of J is");
Button a1=new Button("AAA");
Button a2=new Button("BBB");
a1.setBounds(x2,y2,70,30);
y2=y2+40;
a2.setBounds(x3,y3,70,30);
}
}
}