-1
我想設置的圖標爲一個JLabel圖標,可以有人給我舉例語法我如何設置的JLabel
我已經試過這樣:
JLabel icon = new JLabel();
ImageIcon chromo = createImageIcon("res/icon.png");
panel.add(icon);
icon.setIcon(chromo);
我想這個標籤沒後根本不會出現在面板上。
我想設置的圖標爲一個JLabel圖標,可以有人給我舉例語法我如何設置的JLabel
我已經試過這樣:
JLabel icon = new JLabel();
ImageIcon chromo = createImageIcon("res/icon.png");
panel.add(icon);
icon.setIcon(chromo);
我想這個標籤沒後根本不會出現在面板上。
JLabel icon = new JLabel();
ImageIcon chromo = createImageIcon("res/icon.png");
icon.setIcon(chromo);
panel.add(icon);
不要忘記檢查你的佈局....如果你絕對需要添加界
icon.setBounds(startX,startY,width,height);
_if其絕對值你需要添加bounds_ Nah,如果它是絕對的,你需要切換到'LayoutManager' – Robin 2014-10-18 08:57:42
凡在項目這一形象在什麼位置?你是否檢查過圖像是否爲空? 'createImageIcon'方法是什麼樣的? – 2014-10-18 01:30:05
它位於一個名爲res的包中,其名稱爲icon.png so res/icon.png – 2014-10-18 01:34:43
請顯示'createImageIcon'方法\ – 2014-10-18 01:35:31