MediaTracker, but no Component

I need to load images using an application but I don't have any components to construct a mediatracker.  What is most commonly done in this case?  Is there a component somewhere in the toolkit for this, or do I just create my own.  I realize I can do this:
new MediaTracker(new JLabel());
But why isn't their a default constructor for such a common case?  Am I missing something?
LVL 1
wgilsterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
0
wgilsterAuthor Commented:
Great for 1.4 but what about 1.3?   No ImageIO class
0
CEHJCommented:
>>but what about 1.3?

You can make things easier by doing

Image image = new ImageIcon("x.jpg").getImage();

0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

wgilsterAuthor Commented:
I have a stream of bytes, not a filename that will be turned into an image.
0
CEHJCommented:
Use a ByteArrayOutputStream (let it be 'baos') and then do

Image image = new ImageIcon(baos.toByteArray()).getImage();

0
wgilsterAuthor Commented:
Great for 1.4 but what about 1.3?  No ByteArrayOutputStream class.  

Do I have to read it into an array?  If so, let's get back to the mediatracker...
0
wgilsterAuthor Commented:
Sorry, My bad, ByteArrayOutputStream is there.

Do I have to write my inputstream to the outputstream?
0
CEHJCommented:
>>No ByteArrayOutputStream class.  

It has been in the API since Java 1.0
0
CEHJCommented:
>>Do I have to write my inputstream to the outputstream?

You read the bytes from your 'stream of bytes' then write them to the baos
0
wgilsterAuthor Commented:
I figured it out, ImageIcon uses a mediatracker with an anonymous class like this...

    protected final static Component component = new Component() {};
    protected final static MediaTracker tracker = new MediaTracker(component);

That's what I'll do.
0
CEHJCommented:
Why not just use the ImageIcon as i mentioned?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wgilsterAuthor Commented:
My entire class was based around the MediaTracker with a null parameter, but I kept getting NullPointerExceptions.  I won't have to change my program at all this way.  But you led me to the answer...
0
CEHJCommented:
8-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.