它表示构造函数JPanel(ImageIcon)未定义。
以下是我的部分代码
public Method_1(Test aa) {
this.aa = aa;
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 730, 540);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
//JPanel panel = new JPanel();
BufferedImage myPicture = ImageIO.read(new File("method_1.png"));
JPanel picLabel = new JPanel(new ImageIcon(myPicture));
add(picLabel);
picLabel.setBounds(12, 34, 369, 175);
答案 0 :(得分:1)
变化:
JPanel picLabel = new JPanel(new ImageIcon(myPicture));
要:
JLabel picLabel = new JLabel(new ImageIcon(myPicture));