为什么没有出现应有的图形
import java.awt.*;import java.applet.*;
import java.awt.event.*;
public class NoScrollPain extends Applet
{
ScrollPane viewer; //声明了一个ScrollPane,用来封装视口和滚动杆。
Map map;
public void init()
{
viewer=new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
viewer.getHAdjustable().setUnitIncrement(5); //返回对水平滚动杆的引用。
viewer.getHAdjustable().setBlockIncrement(50);
viewer.getVAdjustable().setUnitIncrement(5); //返回对垂直滚动杆的引用。
viewer.getVAdjustable().setBlockIncrement(50);
setLayout(new BorderLayout());
add("Center",viewer);
map=new Map();
viewer.add(map);
}
}
class Map extends Canvas
{
Map()
{
setSize(300,200);
}
public void pain(Graphics g)
{
g.setColor(Color.white);
g.fillRect(0,0,300,200);
g.setColor(Color.red);
g.drawLine(0,100,100,100);
g.drawLine(100,100,100,0);
g.drawLine(125,0,125,100);
g.drawLine(125,100,300,100);
g.drawLine(0,125,200,125);
g.drawLine(200,125,200,200);
g.drawLine(225,200,225,125);
g.drawLine(225,125,300,125);
g.drawString("主要街道",100,120);
}
}