「Java/swing/サンプル/画像表示」の編集履歴(バックアップ)一覧はこちら

Java/swing/サンプル/画像表示」(2013/03/09 (土) 21:23:30) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

*** 解説 swingで、画像を表示するサンプルです。 *** ポイント + ImageIconクラスでアイコンとして画像を読み込む + JLabelにアイコンを設定 大きさも変えずただ表示するだけならとっても簡単です。 *** 実行結果 #ref(swing 画像表示サンプル1.png) *** ソース &ref(ImageTest1.java) #highlight(java) {{ import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; // swing 画像表示サンプル // ポイント1.ImageIconクラスでアイコンとして画像を読み込む // ポイント2.JLabelにアイコンを設定 // 大きさも変えずただ表示するだけならとっても簡単です。 public class ImageTest1 extends JFrame { public static void main(String[] args) { new ImageTest1(); } public ImageTest1() { setTitle("swing 画像表示サンプル1"); // ポイント1.ImageIconクラスでアイコンとして画像を読み込む ImageIcon icon = new ImageIcon("logo3w.png"); // ポイント2.JLabelにアイコンを設定 JLabel l = new JLabel(icon); add(l); // ついでにJFrameのアイコンにも設定 setIconImage(icon.getImage()); setDefaultCloseOperation(EXIT_ON_CLOSE); setBounds(100, 100, 300, 200); setVisible(true); } } }} *** アフィリエイト #amazon2()
* 解説 swingで、画像を表示するサンプルです。 * ポイント + ImageIconクラスでアイコンとして画像を読み込む + JLabelにアイコンを設定 大きさも変えずただ表示するだけならとっても簡単です。 * 実行結果 #ref(swing 画像表示サンプル1.png) * ソース &ref(ImageTest1.java) #highlight(java) {{ import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; // swing 画像表示サンプル // ポイント1.ImageIconクラスでアイコンとして画像を読み込む // ポイント2.JLabelにアイコンを設定 // 大きさも変えずただ表示するだけならとっても簡単です。 public class ImageTest1 extends JFrame { public static void main(String[] args) { new ImageTest1(); } public ImageTest1() { setTitle("swing 画像表示サンプル1"); // ポイント1.ImageIconクラスでアイコンとして画像を読み込む ImageIcon icon = new ImageIcon("logo3w.png"); // ポイント2.JLabelにアイコンを設定 JLabel l = new JLabel(icon); add(l); // ついでにJFrameのアイコンにも設定 setIconImage(icon.getImage()); setDefaultCloseOperation(EXIT_ON_CLOSE); setBounds(100, 100, 300, 200); setVisible(true); } } }} * アフィリエイト #amazon2()

表示オプション

横に並べて表示:
変化行の前後のみ表示: