Results 1 to 4 of 4
  1. #1
    spydevil is offline Member
    Join Date
    Mar 2013
    Rep Power

    Default BufferedImage Problem

    Java Code:
    public class image{
    	JFrame pen = new JFrame();
    	BufferedImage bI;
    	public image() {
    		pen.setBounds(150, 100, 613, 213);
    		try {
    			URL url = new URL("");
    			bI =;
    		} catch (IOException e) {
    	public void paintComponent(Graphics g){
    		Graphics2D g2 = (Graphics2D)g;
    		g2 = bI.createGraphics();
    		g2.drawImage(bI, null, 0, 0);

    Why dont work?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: BufferedImage Problem

    What does "don't work" mean?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: BufferedImage Problem

    Recommended reading: Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    Note carefully which Graphics reference is used for custom painting.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

    Default Re: BufferedImage Problem

    To expand on what Tolls is asking, it's hard to answer questions like "why doesn't this work?" without knowing what's not working about it. We don't know for sure what doesn't work for you- whether it results in a compiler error, a runtime error, an unwanted or unexpected behavior, or something else entirely. And since this isn't an SSCCE, we can't run it to see for ourselves.

    In this case it's fairly obvious what you're doing wrong, so I highly recommend taking Darryl's advice. But in the future, try to ask a specific technical question (and provide an SSCCE) instead of asking general questions. It's much easier to answer "I was expecting this code to do XYZ, but it does ABC instead, what's going on?" than it is to answer questions like "why doesn't this work?" with no other information.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

Similar Threads

  1. BufferedImage problem
    By Jedan_covik in forum New To Java
    Replies: 5
    Last Post: 08-31-2012, 07:13 PM
  2. BufferedImage not going to GC
    By vspin in forum New To Java
    Replies: 11
    Last Post: 07-03-2012, 10:42 AM
  3. Problem Drawing Grid with BufferedImage.
    By Shikatsu in forum Java 2D
    Replies: 10
    Last Post: 11-26-2011, 01:01 AM
  4. Problem with JFileChooser and BufferedImage Class
    By toro1984 in forum AWT / Swing
    Replies: 3
    Last Post: 11-03-2010, 11:09 AM
  5. free memory of bufferedimage problem
    By mr_empty in forum Java 2D
    Replies: 2
    Last Post: 01-17-2010, 07:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts