Header Ads

  • Breaking Now

    How will you add a panel to a frame?

    Here goes the snippet:

    import javax.swing.*;

    public class XYZ extends JFrame{

    public XYZ(){

    JPanel panel =new JPanel();

    this.getContentPane().add(panel);

    }

    public static void main (String args[]){

    XYZ obj=new XYZ();

    obj.setVisible(true);

    }

    }

    Post Top Ad

    Post Bottom Ad