zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package tbDataModel;
import java.awt.Image;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
 
public class Map  {
    int x;
    int y;    
    int x_Pixel;
    int y_Pixel;
    Image image;//±³¾°Í¼Æ¬
    public int getX_Pixel() {
        return x_Pixel;
    }
    public void setX_Pixel(int x_Pixel) {
        this.x_Pixel = x_Pixel;
    }
    public int getY_Pixel() {
        return y_Pixel;
    }
    public void setY_Pixel(int y_Pixel) {
        this.y_Pixel = y_Pixel;
    }
 
    
    public int getX() {
        return x;
    }
    public void setX(int x) {
        this.x = x;
    }
    public int getY() {
        return y;
    }
    public void setY(int y) {
        this.y = y;
    }
 
 
    public JLabel getMapJlabel(String name) {    
        URL resource=this.getClass().getResource(name);//»ñÈ¡µØÍ¼Í¼Æ¬        
        ImageIcon icon=new ImageIcon(resource);
        //ÉèÖÃiconµÄ´óС
        icon.setImage(icon.getImage().getScaledInstance(getX_Pixel(), getY_Pixel(),
                Image.SCALE_DEFAULT));
 
        JLabel mapLabel=new JLabel(icon,JLabel.LEFT);//´´½¨Ò»¸öµØÍ¼±êÇ©
        mapLabel.setBounds(getX(), getY(), getX_Pixel(), getY_Pixel()); 
        return mapLabel;
    }
 
 
}