[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PictureBox in Java

Posted on 2004-11-30
7
Medium Priority
?
6,545 Views
Last Modified: 2008-01-09
Hey experts,

Is there something like a JPictureBox in java, in which we can display a bitmap or jpeg image??
0
Comment
Question by:mte01
  • 4
  • 2
7 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 12707630
any container can display a picture... just call paintPicture method of Graphics object
0
 
LVL 3

Author Comment

by:mte01
ID: 12707687
you mean something like this:

JPanel jp = new JPanel();
jp.getGraphics().paintPicture("picture.bmp");
0
 
LVL 3

Author Comment

by:mte01
ID: 12707799
Is my above code correct according to what you said bobbit31 ??
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Accepted Solution

by:
udo_borkowski earned 800 total points
ID: 12707822
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
 
LVL 18

Expert Comment

by:bobbit31
ID: 12707836
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
 
LVL 3

Author Comment

by:mte01
ID: 12707846
OK....that's what I needed...thanks!
0
 
LVL 3

Author Comment

by:mte01
ID: 12707877
udo_borkowski's mthod is much easier....
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question