![](/img/trans.png)
[英]Open a JFrame from another, without opening a brand new one every time
[英]image in a brand new jframe?
我只是在尋找一個將創建一個新的jframe的類,其中顯示了在項目的src文件夾中找到的圖像“ rules.jpg”。
編輯 :我想出了如何做到這一點,但是當我將其導出到罐子中時,仍然無法顯示圖像,有人有什么建議嗎?
要從罐子中加載圖像,您將需要以其他方式進行訪問。 有一個很好的Swing教程可以做到這一點:
http://download.oracle.com/javase/tutorial/uiswing/components/icon.html#getresource
這是本教程的一些相關代碼:
java.net.URL imageURL = myDemo.class.getResource("images/myImage.gif");
...
if (imageURL != null) {
ImageIcon icon = new ImageIcon(imageURL);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.