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 に BorderLayout を使用していて、JPanel のサイズが必要であることに注意してください。
JPanelメソッドgetWidth()を試すことができますgetHeight()。
JPanel
getWidth()
getHeight()
int getWidth(); int getHeight();
の高さと幅を返しJPanelます。
JPanelメソッドを使用しての境界を取得することもできますgetBounds()。
getBounds()
Rectangle getBounds();
Rectangle境界のa を返します。これを使用して、の位置とサイズを取得できますJPanel。
Rectangle