如何在Java Creator上插入图像

时间:2017-07-01 02:55:50

标签: java

我在Java Creator上寻求帮助,在程序中使用图像时遇到了一些麻烦。

我尝试使用URL模式和桌面模式。

This is how it looks on my program This is the code

//这是我试图做图像的地方

    if(menu==1)
    {
       final ImageIcon icon = new ImageIcon(new URL("http://prntscr.com/fq9ary"));  
    Circulo obj1 = new Circulo();
    obj1.asignar1(radio);

    input = JOptionPane.showInputDialog(null,"\t\t CIRCULO \nLa longitud del Circulo es: "+obj1.calcularLong()+"\n El area del Circulo es: "+obj1.calcularArea(), icon);

    }  } }     

//

1 个答案:

答案 0 :(得分:0)

试试这个

if(menu==1)
{
   URL url = new URL("http://prntscr.com/fq9ary");
   BufferedImage img = ImageIO.read(url);
   final ImageIcon icon = new ImageIcon(img);  
   Circulo obj1 = new Circulo();
   obj1.asignar1(radio);
   input = JOptionPane.showInputDialog(null,"\t\t CIRCULO \nLa longitud del Circulo es: "+obj1.calcularLong()+"\n El area del Circulo es: "+obj1.calcularArea(), icon);
}