本帖最後由 黃宥華 於 2021-9-6 23:09 編輯
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.ImageIcon;
- public class Ch14 {
-
- private JFrame fm;
- private JLabel lb;
- private ImageIcon icon;
-
- Ch14()
- {
- icon=new ImageIcon(Ch14.class.getResource("/01.jpg"));
- lb=new JLabel(icon);
- lb.setBounds(0, 0, 399, 300);
-
- fm=new JFrame("ImageIcon 類別");
- 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) {
- new Ch14();
- }
- }
複製代碼 |