473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Loading pictures

168 100+
hi everyone

how can i load a picture which i want to use in my program?
actually i have wore this code below but i guess the problem is i
dont know how to add the BufferedImage to the Frame, i will be
grateful if u help me

regards
razieh

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;

public class Target extends JFrame
{

BufferedImage img;

public Target()
{
try
{
img = ImageIO.read(new File ("C:\\Target.jpg"));
setDefaultCloseOperation (EXIT_ON_CLOSE);
setVisible (true);
setSize(500,500);

}
catch(IOException e)
{
System.out.println("file does not exist");
}
}
public static void main(String []args)
{
new Target();

}
}//end of class
Jan 21 '09 #1
1 1246
r035198x
13,262 8TB
Where on the frame do you want to add it? One option is to have a JLabel and set it's Icon to be that image.
Jan 21 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Doug van Vianen | last post by:
Hi, Some of my applets take some time to load leaving a blank applet panel and the user wondering if anything will be coming up on it. Some applet games, however, have a simple message such as...
1
by: Jammer | last post by:
I've managed to construct an ASP page that reads JPG file names from a directory, then constructs a page with a table of links to bigger JPG pictures. I have a big problem... If the page...
3
by: Nathan | last post by:
Hi, I have a project with various forms that each include a number of picture boxes and panels with background images. When these forms first load, they kind of load in "pieces", with the...
2
by: nick.taylor | last post by:
Hi, I've been trying for weeks to figure out this problem. I'm developing a simple Javascript app that loads an XML file from a server, parses the contents, and displays them. But I am...
2
by: brianflannery | last post by:
Greetings! My situation is this. I currently have a database of which in a form displays jpeg pictures (one at a time) which are linked to the db and stored in a separate folder. I have set up a...
1
by: kelvinweb | last post by:
Hi All, How to calculate web page loading time on client and send back result to server side ? Urgent ! Thanks alot !
0
by: acknowledged74 | last post by:
Hi I've been looking around for sometime but can't seem to find any tutorials on page loading. i.e. when the elements ( buttons, pictures etc) wiz onto the screen from different places with noises...
5
by: Danny | last post by:
Hi, we have just uploaded our first APS.NET webpage some days ago. Now we had to notice that it takes soo long until the page is shown. About 15 seconds. First we thought, maybe it's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.