返回列表 發帖
  1. import javax.swing.ImageIcon;
  2. import javax.swing.JFrame;
  3. import javax.swing.JLabel;

  4. public class Ch02 {
  5.         private JFrame fm;
  6.         private JLabel l;
  7.         private ImageIcon icon;
  8.         Ch02(){
  9.                 icon=new ImageIcon(Ch02.class.getResource("pic/01.jpg"));
  10.                
  11.                 l=new JLabel(icon);
  12.         l.setBounds(0, 0, 399, 300);
  13.       
  14.         fm=new JFrame("ImageIcon 類別");
  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(l);
  21.         }

  22.         public static void main(String[] args) {
  23.             new Ch02();

  24.         }

  25. }
複製代碼

TOP

返回列表