JPanel scorePanel = new JPanel();
scorePanel.setBackground( new Color( 95 , 8 , 248 , 255 ));
JLabel scoreLabel = new JLabel( "Score : 0" );
scoreLabel.setForeground( Color.white );
scoreLabel.setFont( new Font( "Cambria" , Font.BOLD , 20 ) );
scorePanel.add(scoreLabel);
Dimension d =new Dimension( scorePanel.getSize() );
System.out.println(d);
The output of this snippet when run along with the whole code is-java.awt.Dimension[width=0,height=0]
Why do i get this output, when in scorepanel i have a label of size 20 ? Is this the actual size of scorepanel ?