?? mappanel.java
字號:
/**
* @(#)MapPanel.java
* @A panel used to draw map.
*
* @Link Scholes
* @version 1.00 2008/7/21
*/
package GUI;
//Java core packages
import java.awt.*;
//Java extension packages
import javax.swing.*;
public class MapPanel extends JPanel
{
private int type;
private ImageIcon icon;
//construct a map panel with specified type
public MapPanel(int n)
{
type = n;
setPreferredSize(new Dimension(32,32));
setVisible(true);
}
//get the type of the map panel
public int getType()
{
return type;
}
//set the map panel with the specified type
public void setType(int n)
{
type = n;
repaint();
}
//draw the picture representing the type of the map panel
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
icon = new ImageIcon("img\\" + type + ".jpg");
g.drawImage(icon.getImage(),0,0,null);
}
} //end class MapPanel
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -