还是关于做地图的问题,设计的差不多了,还要请大家改进!

socoolyuanyuan 2003-10-17 02:06:21
我现在已经做出一个可以在地图上看坐标的程序,可是还是不知道怎么把北京二字变为可点击的,大家继续帮忙!程序如下: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中就可以运行了,只是不太好看。请大家帮忙做的人性化些,怎样才能把鼠标放在北京二字上就会出现坐标?而不用点击后才出现?我现在要的是点击后出现北京市地图!谢谢大家,一起完成这个程序,好吗?
...全文
30 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
socoolyuanyuan 2003-10-20
  • 打赏
  • 举报
回复
没人帮忙吗?呜·!
socoolyuanyuan 2003-10-20
  • 打赏
  • 举报
回复
楼上的,可以留个联系方法吗?QQ或者MSN或者EMAIL!
dwju1981 2003-10-20
  • 打赏
  • 举报
回复
北京两个字可以用<a href="URL">北京</a>,这样当你点的时候调用另外一个APPLET,然后显示北京市的地图应该就可以了!

62,614

社区成员

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

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