返回列表 發帖
本帖最後由 張峻瑋 於 2016-3-26 17:42 編輯
  1. import javax.swing.JFrame;
  2. import javax.swing.JLabel;
  3. import javax.swing.ImageIcon;
  4. public class Ch87 {
  5.     private JFrame fm=new JFrame("ImageIcon 類別");
  6.     private JLabel lb;
  7.     private ImageIcon icon;
  8.     Ch87()
  9.     {
  10.                 icon=new ImageIcon(Ch87.class.getResource("pic/01.jpg"));
  11.                
  12.                 lb=new JLabel(icon);
  13.                 lb.setBounds(0, 0, 399, 300);
  14.                
  15.                 fm.setBounds(100, 100, 405, 328);
  16.                 fm.setVisible(true);
  17.                 fm.setResizable(false);
  18.                 fm.setLayout(null);
  19.                 fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  20.                 fm.add(lb);
  21.                
  22.                
  23.     }
  24.         public static void main(String[] args) {
  25.                 Ch87 app=new Ch87();

  26.         }

  27. }
複製代碼

TOP

返回列表