public Image createImage(int width,
int height)
Creates an off-screen drawable image to be used for double buffering. Parameters:
width - the specified width
height - the specified height
Returns:
an off-screen drawable image, which can be used for double buffering. The return value may be null if the component is not displayable. This will always happen if GraphicsEnvironment.isHeadless() returns true
public boolean isDisplayable()
Determines whether this component is displayable. A component is displayable when it is connected to a native screen resource.
A component is made displayable either when it is added to a displayable containment hierarchy or when its containment hierarchy is made displayable. A containment hierarchy is made displayable when its ancestor window is either packed or made visible. A component is made undisplayable either when it is removed from a displayable containment hierarchy or when its containment hierarchy is made undisplayable. A containment hierarchy is made undisplayable when its ancestor window is disposed.
Returns:
true if the component is displayable, false otherwise
int height)
Creates an off-screen drawable image to be used for double buffering. Parameters:
width - the specified width
height - the specified height
Returns:
an off-screen drawable image, which can be used for double buffering. The return value may be null if the component is not displayable. This will always happen if GraphicsEnvironment.isHeadless() returns true
public boolean isDisplayable()
Determines whether this component is displayable. A component is displayable when it is connected to a native screen resource.
A component is made displayable either when it is added to a displayable containment hierarchy or when its containment hierarchy is made displayable. A containment hierarchy is made displayable when its ancestor window is either packed or made visible. A component is made undisplayable either when it is removed from a displayable containment hierarchy or when its containment hierarchy is made undisplayable. A containment hierarchy is made undisplayable when its ancestor window is disposed.
Returns:
true if the component is displayable, false otherwise
解决方案 »
- Java SE代码中能不能控制代开网页的类型
- 新手上路: 一个简单的package和import问题!高手帮帮忙!
- java链接SqlServer2000数据库的链接文怎么写啊。高人指教!
- 如果把编译好的.class转换成exe可执行文件?
- 里面的测试小程序为什么会报错:java.lang.IllegalThreadStateException
- awt的基础问题
- jb6中开发entity bean当structure面板的列类型发生变化时,如何更新已生成的bean
- 请问如何让浏览器自动安装指定的某一个插件
- int类型的数据的引用问题
- 有 float toFloat(int x){ return x/65536.0f;},不理解为什么除以65536.0f,请高手解释
- JAVA程序在哪运行呀!
- 该异常啥意思~
但不是很懂楼上说得我想在JFrame上绘画,由于要使用双缓冲,所以调用this.createImage创建离屏表面
A component is displayable when it is connected to a native screen resource.
是否只能用awt的控件.createImage才不返回null?再请朋友们
不会吧,好象都是null吧
一般都是Image i=createImage(300,500);
Graphics g=i.getGraphics();
g.drawxxxx();
Image i=createImage(300,500); 就是这句话出问题,i返回的是null呀~!
BufferedImage bimage = (BufferedImage)component.createImage(width, height);
if (bimage == null) {
// The component is not visible on the screen
}这说明你必须在一个屏幕上可见的component对象上调用该方法。
可见的component对象?
可见呀,我的button,Panel都是可见的呀,但都返回null你可以写个程序亲自试试看。