<pre>
import java.awt.*;
import java.awt.event.*;
class btn {
public static void main(
String s[]){
Frame w = new Frame();
Panel p = new Panel();
Panel p1 = new Panel();
Panel p2 = new Panel();
Button b = new Button("ok");
Button b1 = new Button("cancel");
Button b2 = new Button("exit");
li l= new li();
b.addActionListener(l);
w.setLayout(new GridLayout(3,1));
w.add(p);
w.add(p1);
w.add(p2);
p2.setBackground(Color.blue);
p2.setLayout(new FlowLayout());
p2.add(b);
p2.add(b1);
p2.add(b2);
p1.setBackground(Color.green);
p1.setLayout(new FlowLayout());
p1.add(b);
p1.add(b1);
p1.add(b2);
p.setBackground(Color.red);
p.setLayout(new FlowLayout());
p.add(b);
p.add(b1);
p.add(b2);
w.setVisible(true);
w.setSize(200,200);
}
}
class li implements ActionListener{
public void actionPerformed(ActionEvent e){
System.out.println("hai");
}
}
</pre>
I just want to dispaly three panels horizontally with diff colors
and each panel must have three btns arranged left to right.
But i am getting in only one panel ie last one.How to rectify it??