返回列表 發帖
  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 lb;
  7.         private ImageIcon icon;

  8.         Ch02(){

  9.                 icon=new ImageIcon(Ch02.class.getResource("pic/Koala.jpg"));
  10.                
  11.                 lb=new JLabel(icon);
  12.                 lb.setBounds(0, 0, 399, 300);

  13.                 fm=new JFrame("ImageIcon 類別");
  14.                 fm.setBounds(100, 100, 405, 328);
  15.                 fm.setVisible(true);
  16.                 fm.setResizable(false);
  17.                 fm.setLayout(null);
  18.                 fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  19.                 fm.add(lb);      
  20.         }
  21.         public static void main(String[] args) {
  22.                  Ch02 app=new Ch02();

  23.         }

  24. }
複製代碼

TOP

返回列表