PictureBox in Java

Hey experts,

Is there something like a JPictureBox in java, in which we can display a bitmap or jpeg image??
LVL 3
mte01Asked:
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.

bobbit31Commented:
any container can display a picture... just call paintPicture method of Graphics object
0
mte01Author Commented:
you mean something like this:

JPanel jp = new JPanel();
jp.getGraphics().paintPicture("picture.bmp");
0
mte01Author Commented:
Is my above code correct according to what you said bobbit31 ??
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

udo_borkowskiCommented:
You can load the image/picture as an "Icon" and display it in a label.

Example:

Icon icon = new ImageIcon(new URL("http://www.google.de/intl/de_de/images/logo.gif"));
JLabel label = new JLabel(icon);




Notice that an Icon can be of any size.
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
bobbit31Commented:
actually, i meant overload the paint() method of the container:

public void paint(Graphics g) {
  g.drawImage(img, x, y, null);
}

where img is an instance of Image class
0
mte01Author Commented:
OK....that's what I needed...thanks!
0
mte01Author Commented:
udo_borkowski's mthod is much easier....
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.