I Want to add mulitple Panels on the Frame at the specific position. And Each panel should contain multiple components at the desired location in the panel( I use setLocation for this purpose). But this code do not solve my purpose. Its shows only JPanel p2(RED in color) and Buttons b1,b2.
Can Anyone tell me Where I am wrong in the code or suggest any other alternative to solve my purpose.
Here is the CODE:
import java.awt.*;
import javax.swing.border.*;
import javax.swing.*;
public class Class3 extends JFrame {
JButton b1,b2;
JPanel p,p2;
Border blackline;
//Container con=getContentPane();
public Class3(String s)
{
super(s);
setLayout(new BorderLayout());
// p=new JPanel();
//p2=new JPanel();
p=(JPanel)getContentPane();
p2=(JPanel)getContentPane();
p.setLayout(null);
p2.setLayout(null);
b1=new JButton("Ok");
b1.setLocation(350,650);
b1.setSize(80, 20);
p.add(b1);
p.setBackground(Color.GREEN);
blackline = BorderFactory.createLoweredBevelBorder();
p.setBorder(blackline);
p.setLocation(0,500);
p.setSize(650, 270);
// p.setBorder(blackline);
b2=new JButton("Ok");
b2.setLocation(850,650);
b2.setSize(80, 50);
p2.add(b2);
p2.setBackground(Color.RED);
p2.setLocation(650, 500);
p2.setSize(650, 270);
}
public static void main(String ar[])
{
Class3 c=new Class3("ADMIN");
c.setSize(1300, 770);
c.setLocation(0, 0);
c.setVisible(true);
}
}