本帖最後由 張峻瑋 於 2016-3-26 17:42 編輯
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.ImageIcon;
- public class Ch87 {
- private JFrame fm=new JFrame("ImageIcon 類別");
- private JLabel lb;
- private ImageIcon icon;
- Ch87()
- {
- icon=new ImageIcon(Ch87.class.getResource("pic/01.jpg"));
-
- lb=new JLabel(icon);
- lb.setBounds(0, 0, 399, 300);
-
- fm.setBounds(100, 100, 405, 328);
- fm.setVisible(true);
- fm.setResizable(false);
- fm.setLayout(null);
- fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- fm.add(lb);
-
-
- }
- public static void main(String[] args) {
- Ch87 app=new Ch87();
- }
- }
複製代碼 |