I need a good example of how to load and draw an image in Java -
i need example of how load , draw image on java.
i've checked oracle , javalobby, , seem great, i'm new this, nearing end of semester too, oop class end , may not have local person ask this, turn guys.
all need example actual image locations , stuff... stuff (string ref) doesn't me compared ("c:\\lalala.jpg")
, know? i'm asking see actual code laods , draws image. simpler better.
also, here code i'm working now; class of image work:
package chatmain; import javax.swing.*; import java.io.*; import java.awt.*; import java.awt.image.*; import javax.imageio.*; public class chatimage extends jpanel { public static bufferedimage bgimg; public chatimage () { super(); try { bgimg = imageio.read(new file("dnframe.png")); } catch (ioexception e) { joptionpane.showmessagedialog(null, "the image did not load properly!", "oh oh!", joptionpane.error_message); } } public void paintcomponent(graphics g) { g.drawimage(bgimg, 0, 0, null); repaint(); } }
and here part of class calls one:
public class chatwindow extends chatimage { private borderlayout bl; private flowlayout fl; private jframe window; private jmenubar menubar; private jpanel mainpane; private jmenu file; private jmenuitem save; private jmenuitem load; private jmenuitem exit; private jmenu options; private jmenuitem font; private jmenuitem volume; private jmenu about; private jmenuitem info; private jpanel outputpane; private jpanel inputpane; private jbutton send; private jlabel me; private jlabel you; private jtextarea op_display; private jtextfield ip_display; private jscrollpane op_dispscroll; private jscrollpane ip_dispscroll; public chatwindow(){ init_comp(); } public void init_comp(){ chatimage image = new chatimage(); bl = new borderlayout(); fl = new flowlayout(); // initialize jframe window = new jframe("orlachat"); window.setdefaultcloseoperation(jframe.exit_on_close); window.add(image); window.setsize(300, 400); window.setlayout(bl); window.setlocationrelativeto (null);
Comments
Post a Comment