Topic: 请教高手!!!!!!!!! |
Print this page |
1.请教高手!!!!!!!!! | Copy to clipboard |
Posted by: jsxww2002 Posted on: 2005-04-18 08:47 请问如何修该下列程序,可以用鼠标拖动图片? import java.applet.*; import java.awt.*; import java.awt.event.*; class Imagecanvas extends Canvas { Toolkit tool; Image myimage; Imagecanvas() { setSize(200,200); tool=getToolkit(); myimage=tool.getImage("image.jpg"); } public void paint(Graphics g) { g.drawImage(myimage,10,10,myimage.getWidth(this),myimage.getHeight(this),this); } } public class caru { public static void main(String args[]) { Imagecanvas canvas=new Imagecanvas(); { Frame frame=new Frame(); frame.setLayout(new BorderLayout()); frame.add(canvas,"Center"); frame.add("South",new Label()); frame.add("West",new Label()); frame.add("North",new Label()); frame.setSize(400,300); frame.setVisible(true); frame.pack(); frame.addWindowListener(new CloseWin()); } } } |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |