簡體   English   中英

帶有圖像的小程序

[英]Applet with image

我的主類(擴展了applet)顯示的是帶有絕對路徑的圖像,但是我不知道如何使它從html所在的文件夾中獲取路徑。

    try {
        tutorial2 = TextureLoader.getTexture("PNG", new FileInputStream(
                new File("D:/eclipse/workspace/Final/res/tutorial2.png")));

    } catch (IOException e) {
        e.printStackTrace();
        System.err.println("Nu s-a gasit imaginea");
    }

但是我的html小程序位於另一個dir中,並且當您移動html仍要查看圖像時,我希望這樣做。

復制圖像(tutorial2.png)並將該圖像粘貼到保存上述類的文件夾中,然后執行此操作

tutorial2 = TextureLoader.getTexture("PNG", new FileInputStream(
                new File("tutorial2.png")));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM