java - Need help displaying my Image using paint -


but ive spent several hours trying run code , isnt working. firstly supposed print image screen. far doesnt want print image still print rectangle , string. have tried many things, im not sure if loading image anymore. know doing wrong? im using netbeans if helps

        public class screen extends jpanel implements runnable {          public thread thread = new thread(this);         private image cat;  public screen(frame frame) {          thread.start(); } public void run(){     system.out.println("this running");     loadpic();     repaint();          try{         thread.sleep(1);      } catch(exception e) {}     }  public void loadpic(){     cat = new imageicon("caticon1.png").getimage();     system.out.println("image loaded!");     repaint(); } public void paint(graphics g){      g.drawstring("sup tho!", 250, 250);     g.fillrect(50,50,50,50);      system.out.println("this works?");            g.drawimage(cat, 0, 0, null);           system.out.println("cat should drawn");  }  } 

i run code every things seems working , image displayed correctly sure image loaded? try anther image , make sure the image in correct directory of project.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -