怎样把网上下载的图形中的字变成可点击的呢?

socoolyuanyuan 2003-10-16 11:36:00
比如,我下载一全国地图,上面的北京二字本来是不可点击的,怎样把它变成可点击的?并且点击后可以出现另一幅地图:即北京市地图呢?各位能详细点说说吗?
...全文
69 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
socoolyuanyuan 2003-10-17
  • 打赏
  • 举报
回复
我现在已经做出一个可以在地图上看坐标的程序,可是还是不知道怎么把北京二字变为可点击的,大家继续帮忙!程序如下:import java.awt.*;
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中就可以运行了,只是不太好看。请大家帮忙做的人性化些,怎样才能把鼠标放在北京二字上就会出现坐标?而不用点击后才出现?我现在要的是点击后出现北京市地图!谢谢大家,一起完成这个程序,好吗?
littlecong 2003-10-16
  • 打赏
  • 举报
回复
用dreamweaver或frontpage更方便一点
希偌 2003-10-16
  • 打赏
  • 举报
回复
<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表示打开连接的方式,这里是新打开一页
socoolyuanyuan 2003-10-16
  • 打赏
  • 举报
回复
我不会啊,能写个程序吗?帮帮我吧!谢谢!
希偌 2003-10-16
  • 打赏
  • 举报
回复
用HTML里的<area>标签
socoolyuanyuan 2003-10-16
  • 打赏
  • 举报
回复
又要等晚上的朋友了!
socoolyuanyuan 2003-10-16
  • 打赏
  • 举报
回复
能详细点说说吗/?谢谢
haode 2003-10-16
  • 打赏
  • 举报
回复
其实是判断一个方框
socoolyuanyuan 2003-10-16
  • 打赏
  • 举报
回复
谢谢,可是怎样看图片上北京二字的坐标点呢?
希偌 2003-10-16
  • 打赏
  • 举报
回复
<img src="file:///C:/TEST/image.jpg" border="0" usemap="#Map">
<map name="Map">
<area shape="rect" coords="240,19,503,59" href="http://xxx.xxx.xxx" target="_blank">
</map>
coords里的坐标参数还是要你自己来定,它表示图片上的坐标点
socoolyuanyuan 2003-10-16
  • 打赏
  • 举报
回复
比如我的地图文件放在C盘的TEST文件夹下,取名为"image.jpg",上述程序应该怎么写?
socoolyuanyuan 2003-10-16
  • 打赏
  • 举报
回复
dreamweaver,frontpage我都不会,还是用beyond_xiruo的方法更现实点,我先试试再说,先谢了 啊!

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧