Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
JFrameで実際のJPanelサイズを取得するにはどうすればよいですか?
0,0コンポーネントやレイアウトは事前に計算されていないため、表示されるまでのサイズになります。
0,0
thePanel.getSize();
これにより、ディメンションが返されます。
パネルのサイズが変更されたときに寸法を表示するために、ComponentListenerを追加することがあります。
編集:JFrameのコンテンツペインのサイズが必要な場合は、
theFrame.getContentPane().getSize();