有两点问题:
1.img为空。
2.没有绘制这个图像。
img = getImage(imgURL, imgPath);
if(img ==null){//判断是不是为空
System.out.println("Image is null!");
}else{//不为空则显示图像
g.drawImage(img,xpoint,ypoint,img.getWidth(this),img.getHeight(this),this);
}
}
1.img为空。
2.没有绘制这个图像。
img = getImage(imgURL, imgPath);
if(img ==null){//判断是不是为空
System.out.println("Image is null!");
}else{//不为空则显示图像
g.drawImage(img,xpoint,ypoint,img.getWidth(this),img.getHeight(this),this);
}
}
解决方案 »
- 怎么把map的key和value分别遍利出来啊?
- 一道类型转换的题
- select 传值问题
- 問一個簡單的問題?標題不知道怎麼起!
- J2SE 1.4 SDK在我的计算机上安装完成后出现问题,总提示非法操作,不知是怎么回事!
- 哪有AWT和SWING的完整源码下载,谁能提供一些,在下万分感谢
- 如何在一个程序中调用并对另一个程序操作
- 有谁用过JasperReports?大家一起来研究一下。
- 准备学java...向大家请教一二...
- 急!JBuilder中出现的问题!!!!!!!!!!!!!!!!!!!!!!1
- javabean与ServletContext如何进行数据的交换?在线等待,请相助!
- 急,一个聊天室程序,为什么两者不能建立连接?
我的html是这样写的:
<html>
<head>
<title>"MyApplet text"
</title>
<body>
<applet code="MyApplet.class" width=500 height=500 /applet>
</body>
</head>
</html>
try {
URL url = new URL(getDocumentBase()+imgPath);
} catch (MalformedURLException e) {
textField1.setText(e.toString());
}
import java.applet.*;
import java.awt.image.*;
import java.awt.image.ImageObserver;
import java.net.URL; public class MyApplet extends Applet implements ImageObserver{
Image img;
String imgPath = "";
int xpoint = 100, ypoint = 100; public void init() { setBackground(Color.white); //设置背景色
setForeground(Color.blue); //设置前景色
Container cp = getContentPane();
cp.add(new JLabel("test.jpg"));}
不就可以了,为什么要用paint