<img src="xxx.jpg" border="0" usemap="#Map">
<map name="Map">
<area shape="rect" coords="240,19,503,59" href="http://xxx.xxx.xxx" target="_blank">
</map>shape表示在图片上的热点区域为方形,coords表示起点和终点的坐标,href表示热点的连接地址,target表示打开连接的方式,这里是新打开一页
<map name="Map">
<area shape="rect" coords="240,19,503,59" href="http://xxx.xxx.xxx" target="_blank">
</map>shape表示在图片上的热点区域为方形,coords表示起点和终点的坐标,href表示热点的连接地址,target表示打开连接的方式,这里是新打开一页
解决方案 »
- 我是大一软件新生,刚上来有个简单问题
- SWT中怎样改变图片大小?
- 急,这代码究竟什么意思?
- hql 是否支持 order by nulls first / last ??
- 求救如何在通过java向已经存在的excel中写入数据?
- 面试时如何介绍自己做的项目
- 请问PrintWriter的flush()方法有何作用?为何每次使用完PrintWriter的println()之后都用一下flush()呢?
- 多线程调用REpaint(),遇到一个问题,谢谢大家
- 请问哪为为可以给我些有关scjp1.4中ASSERTIONS和GARBAGE COLLECTION的教程和习题!
- Primitive 与 String 之间的转换必须采用封装类吗?
- 请叫各位大虾一下,我想在JComboBox中对对应的每一条在添加一个隐藏的值
- TYPE_SCROLL_INSENSITIVE 和 TYPE_SCROLL_SENSITIVE 有何区别?
<map name="Map">
<area shape="rect" coords="240,19,503,59" href="http://xxx.xxx.xxx" target="_blank">
</map>
coords里的坐标参数还是要你自己来定,它表示图片上的坐标点
import java.awt.event.*;
import java.applet.Applet;/*
<APPLET
CODE=Mouse.class
WIDTH=300 //修改为适应图片大小
HEIGHT=200> //修改为适应图片大小
</APPLET>
*/public class Mouse extends Applet implements MouseListener,
MouseMotionListener
{
Image image;
TextField text1;
public void init()
{
text1=new TextField(30);
add(text1);
addMouseListener(this);
addMouseMotionListener(this); image=getImage(getDocumentBase(),"image.jpg"); //参照你的代码增加
}public void paint(Graphics g)
{
g.drawImage(image,150,150,this);
} public void mousePressed(MouseEvent e)
{
if((e.getModifiers()&InputEvent.BUTTON1_MASK)==InputEvent.BUTTON1_MASK)
{
text1.setText("Left mouse button down at"+e.getX()+","+e.getY());
}
else
{
text1.setText("Right mouse button down at"+e.getX()+","+e.getY());
}
}public void mouseClicked(MouseEvent e)
{
text1.setText("You clicked the mouse at"+e.getX()+","+e.getY());
}public void mouseReleased(MouseEvent e)
{
text1.setText("The mouse button went up.");
}public void mouseEntered(MouseEvent e)
{
text1.setText("The mouse entered.");
}public void mouseExited(MouseEvent e)
{
text1.setText("The mouse exited.");
}public void mouseDragged(MouseEvent e)
{
text1.setText("The mouse was dragged.");
}public void mouseMoved(MouseEvent e)
{
text1.setText("The mouse was moved.");
}
}
以上是鼠标事件,大家可以保存为Mouse.java
<html>
<head>
<title>MyMap</title>
</head>
<body>
<applet
code="Mouse.class"
width=300
height=300
>
</applet>
</body>
</html>
以上是一个HTML文件,可保存为map.html,
当然大家还要导入一个地图文件,这里不能帖图,http://www.culturalink.gov.cn/chinamap.htm可以去这下一个放在和刚才两个文件保存在同一个文件夹中。
这样在APPLET中就可以运行了,只是不太好看。请大家帮忙做的人性化些,怎样才能把鼠标放在北京二字上就会出现坐标?而不用点击后才出现?我现在要的是点击后出现北京市地图!谢谢大家,一起完成这个程序,好吗?