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

TOP

返回列表