- package bbs.istak.org.tw;
- import java.awt.BorderLayout;
- import java.awt.EventQueue;
- import java.awt.Image;
- import javax.swing.ImageIcon;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.JLabel;
- public class Test extends JFrame {
- private JPanel contentPane;
- private ImageIcon icon,picon;
- private ImageIcon[] pic,newpic;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Test frame = new Test();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- */
- public Test() {
-
- icon = new ImageIcon(Test.class.getResource("icon.png"));
- Image img = icon.getImage().getScaledInstance(376,208,Image.SCALE_FAST);
- setIconImage(img);
-
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 450, 300);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
-
- JLabel label_0 = new JLabel("New label");
- label_0.setBounds(10, 10, 132, 108);
- contentPane.add(label_0);
-
- JLabel label_1 = new JLabel("New label");
- label_1.setBounds(10, 128, 132, 108);
- contentPane.add(label_1);
-
- JLabel label_2 = new JLabel("New label");
- label_2.setBounds(152, 10, 132, 108);
- contentPane.add(label_2);
-
- JLabel label_3 = new JLabel("New label");
- label_3.setBounds(152, 128, 132, 108);
- contentPane.add(label_3);
-
- JLabel label_4 = new JLabel("New label");
- label_4.setBounds(302, 10, 132, 108);
- contentPane.add(label_4);
-
- JLabel label_5 = new JLabel("New label");
- label_5.setBounds(302, 128, 132, 108);
- contentPane.add(label_5);
-
- pic = new ImageIcon[6];
- newpic = new ImageIcon[6];
- for(int i = 0 ; i < 6 ; i++){
- pic[i] = new ImageIcon(Test.class.getResource("0"+String.valueOf(i+1)+"png"));
-
-
-
- }
- for(int i = 0 ; i < 6 ; i++){
- Image pimg = pic[i].getImage().getScaledInstance(132,108,Image.SCALE_FAST);
- newpic[i] = new ImageIcon(pimg);
-
- }
- }
- }
複製代碼 |