Re: [問題] 請問JFrame左上角的標題icon該如何改變 …
※ 引述《seruze (seruze)》之銘言:
: 我了一個小視窗~想將他上面的icon改掉,不要再用咖啡杯圖示~
: 但是找了幾個方法試過後,好像都不會改變到原來的咖啡..
: 我的看到的方法是這個樣子~
: public sataic void main(String args[])
: {
: ohchat frame = new ohchat();
: ImageIcon icon = new ImageIcon("file_save.gif");
: frame.setIconImage( icon.getImage() );
: .
: .
: .
: .
: .
: }
: 我使用的是windows內的小圖示,也確定圖片是16x16的大小了,但還是沒有辦法
: 取代掉原來的咖啡杯,請問有大大用過相關的功能嗎?希望能指點小弟一二,謝謝!
我試了一下,你的 Code 確實不會把圖示改掉,請嘗試以下寫法:
public static void main(String[] args) throws Exception {
BufferedImage image = ImageIO.read(new File("file_save.gif"));
JFrame frame = new JFrame();
frame.setSize(300, 300);
frame.setIconImage(image);
frame.setVisible(true);
}
經測試是可以換掉左上角的圖示的。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.247.13
推
06/25 14:22, , 1F
06/25 14:22, 1F
推
06/25 14:32, , 2F
06/25 14:32, 2F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):