Link to home
Start Free TrialLog in
Avatar of mte01
mte01Flag for Lebanon

asked on

PictureBox in Java

Hey experts,

Is there something like a JPictureBox in java, in which we can display a bitmap or jpeg image??
Avatar of bobbit31
bobbit31
Flag of United States of America image

any container can display a picture... just call paintPicture method of Graphics object
Avatar of mte01

ASKER

you mean something like this:

JPanel jp = new JPanel();
jp.getGraphics().paintPicture("picture.bmp");
Avatar of mte01

ASKER

Is my above code correct according to what you said bobbit31 ??
ASKER CERTIFIED SOLUTION
Avatar of udo_borkowski
udo_borkowski

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of mte01

ASKER

OK....that's what I needed...thanks!
Avatar of mte01

ASKER

udo_borkowski's mthod is much easier....