Trying to create the simplest application. But, when adding a JPanel component to a JFrame , JPanel does not occupy all the allowable space. The program produces the following result: "java.awt.Dimension[width=0,height=0]" , i.e. the JPanel dimensions are zero. How to make Jpanel placed in a JFrame automatically occupy all the space available in JFrame in Java ? And one could immediately find out these sizes?
Program Listing:
public class Test1 extends JFrame{ Test1() { super("ΠΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅"); setBounds(50,50,1000, 450); JPanel panel = new JPanel(); this.add(panel); System.out.println(this.getComponent(0).getSize()); } public static void main(String[] args) throws IOException { new Test1(); } }
BorderLayoutused by default) - zRrr