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.
JButtonに画像を追加したい。これが私が使用しているコードです:
画像は「Images」というフォルダにあり、たまたまアプリケーションのソースパッケージにあります。JButtonのサイズは正しく調整されていますが、ボタンに画像が表示されていません。誰かが私がこの問題を解決するのを手伝ってもらえますか?ありがとう :)
試すcreate_ImageIcon(Button_NewFile, "src/Images/New File.png");
create_ImageIcon(Button_NewFile, "src/Images/New File.png");
を作成するImageIconと、アプリケーションが起動される相対パスが検索されます。通常、これはsrcフォルダーが配置されているフォルダーにあります。ただし、独立したアプリケーションとして実行する場合は注意してください。
ImageIcon