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中[宽度= 0,高度= 0]这是面板的实际尺寸吗?
为什么会收到此输出,当在scorepanel我有一个20号的标签?是这个记事本的实际大小?
我打包到一个容器后得到这个输出。 –
即使渲染框架? – mre