java - How to place image in source folder and use it in Eclipse -


i teaching myself how use images in eclipse.

i trying code implementing images compile:

    import java.awt.*; import javax.swing.jframe; import java.io.file; import javax.imageio.imageio;  public class imagedemo extends canvas {     image coolface;      public imagedemo() throws exception     {         coolface = imageio.read( new file("jesus.png") );      }      public void paint( graphics g )     {         //           image  , x,  y,         g.drawimage(coolface,100,100,this);          g.setcolor( color.yellow );         g.drawoval(88,88,70,25);     }      public static void main(string[] args) throws exception     {         jframe win = new jframe("image demo");         win.setsize(1024,768);         win.setdefaultcloseoperation(jframe.exit_on_close);         win.add( new imagedemo() );         win.setvisible(true);     }   } 

the problem not know how image in same source folder of code in eclipse.

i think created 1 not know how put image desktop there.

any appreciated. eclipse

generally eclipse starts jvm current directory base of project place on base of project read existing code


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -