我想知道如何将图像添加到消息对话框。我尝试了下面的代码,但找不到图像
else if(button == B){
String text = "blahblahblahblahblah";
JTextArea textArea = new JTextArea(text);
textArea.setColumns(30);
textArea.setLineWrap( true );
textArea.setWrapStyleWord( true );
textArea.setSize(textArea.getPreferredSize().width, 1);
Font font = new Font("Verdana", Font.BOLD, 12);
textArea.setFont(font);
textArea.setForeground(Color.BLUE);
JOptionPane.showMessageDialog(
null, textArea, "Border States", JOptionPane.PLAIN_MESSAGE);
image2 = new ImageIcon(getClass().getResource("borderstates.jpg"));
label2 = new JLabel(image2);
add(label2);