首页 > 编程知识 正文

识别灰度图像的小程序(java图形用户界面编程)

时间:2023-05-03 07:33:17 阅读:72584 作者:3877

iamhavingahardtimefiguringouthowtoshowanimage (orimageicon ) ina Java applet.thefollowingismycode.the picture (test.BMP ) ) doesexistandisontheddrivebutwhenirunthisigettheappletwindowwithnothinginit.cansomebodytellmewhatiammmissingtomaketheimageicon

公共类表单1扩展SJ小程序{

公共语音init (

I=新图像Icon (d : (test.BMP );

}

公共语音绘制(图形) {

I.painticon(this,g,0,0 );

}

}

Thanks、lkdys/p解决方案

参考yourimagethroughanabsolutelocalfilepathmightnotworkwhenyourunyourappletfromaserver.usetheimageicon (结构控制器esourceontheserver.usethejapplet.getcode base (todeterminewhereyourappletoriginant

公共类表单1扩展SJ小程序{

Image i;

公共语音init (

try {

I=imageio.read (newurl (getcode base )、' test.bmp ' );

}catch(malformedurlexceptionex ) )

ex.printStackTrace (;

}catch(ioexceptionex ) {

ex.printStackTrace (;

}

}

公共语音绘制(图形) {

g.drawimage(I,0,0,null );

}

}

edit : imageiosupportsbmpandthechangedsampleworksforme。

edit 23360 ifitstilldoesn ' tdisplaytheimage,try ' ./test.BMP ' becausewhenyourunanappletfromletssayeclipseithasthebindirirage

edit : ifyouputyourtest.bmpintothejarorontheclasspath,youcanloaditusingthesamewaybutreplacing

newURL(getcodebase )、' test.bmp ' ) ) )。

微信

form1. class.get resource (' test.BMP ' ) )。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。