hi,I want to know how to add jpanel to jframe .will this much in my code do? JPanel jp=new jPanel(); jp.setSize(200,50); jp.add(button1);//here i add components jp.add(button2); frame.setContentPane( BorderLayout.CENTER); Am using Grid Bag layout...have already included the code before in this session,so I am not reposting it...thanks in advance
Have you tried compiling that? I don't think so, or you'd have found out that "frame.setContentPane( BorderLayout.CENTER);" will not compile. This method takes a Container, not a String. Don't you mean "frame.setContentPane("jp);"?
Also, "jp.setSize(200,50);" may not work if the parent component's layout manager overrides the size. If the JPanel is your ContentPane I don't think it will cause any problems though.