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);
コード全体と一緒に実行した場合のこのスニペットの出力は、java.awt.Dimension [width = 0、height = 0]
スコアパネルにサイズ20のラベルがあるのに、なぜこの出力が得られるのですか? これ はスコアパネルの実際のサイズですか?