1
我試圖使用JLabel插入圖像到我的GUI。但是它不會出現圖片不出現
這裏是部分我的代碼
public FirstAid() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 700, 507);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new BorderLayout(0, 0));
tabbedPane = new JTabbedPane(JTabbedPane.TOP);
contentPane.add(tabbedPane, BorderLayout.CENTER);
panel = new JPanel();
ImageIcon imageIcon = new ImageIcon("src/method_1.png");
JLabel label = new JLabel(imageIcon);
panel.add(label);
tabbedPane.addTab("name", null, panel, null);
您的編輯和添加的代碼現在改變了整個問題(並使我的答案無效)。該代碼和信息不應該是你的**原始問題**的一部分嗎?此時,我建議您創建併發布[最小代碼示例程序](http://stackoverflow.com/help/mcve)。 – 2015-02-08 14:59:51
然後我創建一個新問題嗎? – friedrojak 2015-02-08 15:02:45
不,我的答案顯然不是*答案,所以不要接受它,然後嘗試在這裏改進您當前的問題。 – 2015-02-08 15:05:40