I want to add
JPanel whose layout is
JPanel contains other components. I have to add
JTable at proper position.
Don’t use a null layout. Learn to use LayoutManagers:
LayoutManagers allow you to properly handle things window resizing or dynamic component counts. They might seem intimidating at first, but they are worth the effort to learn.
As I can remember, the null layout means an absolute position so it will be pretty hard you to count the X point for your JTable left upper corner location. But if you just want to have all panel components one by one you can use FlowLayout() manager as
JPanel panel=new JPanel(new FlowLayout()); panel.add(new aComponent()); panel.add(new bComponent()); panel.add(new JTable());
or if you need to fill the panel you should use GridLayout() as…
int x=2,y=2; JPanel panel=new JPanel(new GridLayout(y,x)); panel.add(new aComponent()); panel.add(new bComponent()); panel.add(new JTable());