i'm use Netbeans
i create JframForm and add a panel to it ,and create new jpanel and add components to it like buttons & textboxs ,finally I'm add the panel 2 to panel 1 but the components of panel 2 not appear and their is no errors.
"how i add the 2nd panel and their components to the 1st one ?"

myJPanelOne.add(myJPanel2nd)

myJPanelOne.add(myJPanel2nd)

the components of myJPanel2nd not appear in panel 1

i'm use Netbeans
i create JframForm and add a panel to it ,and create new jpanel and add components to it like buttons & textboxs ,finally I'm add the panel 2 to panel 1 but the components of panel 2 not appear and their is no errors.
"how i add the 2nd panel and their components to the 1st one ?"

Without posting your code it's hard to guess how your program should work

Without posting your code it's hard to guess how your program should work

myPanle class

public class CustomPanel extends JPanel {

JButton ml = new JButton("my");

    @Override
    public Component add(Component comp) {
        return super.add(ml);
    }
}

main class & form

public class Main  {
    public static void main(String[] args) {
      JFrame window = new JFrame();
      CustomPanel m = new CustomPanel();
      JPanel myPan = new JPanel();
      myPan = m ;
		window.setSize(700, 700);
		window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		window.add(myPan);
		window.setVisible(true);
	}
    }

why components of custompanl not appear in mypan ?

You should probably try adding the CustomPanel instance to the new panel, in your case the instance is myPan.

myPan = m;

Just copies the reference of m to myPan, right now you adding both panels to the frame.

myPan.add(m);

might work

Then add myPan to the frame so

window.add(myPan);

You should probably try adding the CustomPanel instance to the new panel, in your case the instance is myPan.

myPan = m;

Just copies the reference of m to myPan, right now you adding both panels to the frame.

myPan.add(m);

might work

Then add myPan to the frame so

window.add(myPan);

i do that nw but the components still not appear , and there is no errors

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.