Share on Google+Share on Google+

2 Answer(s)      8 years ago
Posted in : Java Beginners


View Answers

August 23, 2008 at 12:00 PM

hai frnd....
"\" is a special character...
i think u must use "\\" whereever u want "\"
try using this......
img = Toolkit.getDefaultToolkit().getImage("C:\\Documents and Settings\\gayathri\\My Documents\\My Pictures\\photo\\Image010.jpg");


img = Toolkit.getDefaultToolkit().getImage("C://Documents and Settings//gayathri//My Documents//My Pictures//photo//Image010.jpg");
hope it work..
thanks and regards

[email protected]

August 27, 2008 at 4:16 PM

Hi friend,

i am sending code.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.JFrame;

public class ImageDisplayTest {
public static void main(String[] args) {
ImagePanel panel = new ImagePanel(new ImageIcon("/home/vinod/amarexamples/cat.gif").getImage());
JFrame frame = new JFrame();

class ImagePanel extends JPanel {

private Image img;
public ImagePanel(String img) {
this(new ImageIcon(img).getImage());
public ImagePanel(Image img) {
this.img = img;


public void paintComponent(Graphics g) {
g.drawImage(img, 0, 0, null);



Read for more information,


Related Tutorials/Questions & Answers:
java awt calender
java awt calender  java awt code for calender to include beside a textfield
JAVA AWT BASE PROJECT  suggest meaningful java AWT-base project
Java AWT event hierarchy
Java AWT event hierarchy  What class is the top of the AWT event hierarchy?  The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy
java awt components - Java Beginners
java awt components  how to make the the button being active at a time..? ie two or more buttons gets activated by click at a time
java awt package tutorial
Java AWT Package In Java, Abstract Window Toolkit(AWT) is a platform independent widget toolkit for windowing, graphics, and user-interface. As the Java programming language, the AWT is also platform-independent. A common set
Create a Container in Java awt
Create a Container in Java awt       Introduction This program illustrates you how to create a container. Container contains several control or tools for develop your
Java AWT
Java AWT  What is meant by controls and what are different types of controls in AWT
Java AWT
Java AWT  What is the relationship between the Canvas class and the Graphics class
Java AWT
Java AWT  How can the Checkbox class be used to create a radio button
Java AWT
Java AWT  What interface is extended by AWT event listeners
Event handling in Java AWT
Event handling in Java AWT     ... events in java awt. Here, this is done through the java.awt.*; package of java. Events are the integral part of the java platform. You can see the concepts
how to include a session class in java awt code - JavaMail
how to include a session class in java awt code  Hi... i have been developing a mini online shopping tool using java awt and websphere MQ as middleware technology.. Iam facing problem in handling MQ calls i need
java-awt - Java Beginners
java-awt  how to include picture stored on my machine to a java frame? when i tried to include the path of the file it is showing error. i have... information, Thanks
Java AWT Components
Java AWT Components      ... components available in the Java AWT package for developing user interface for your program. Following some components of Java AWT are explained :  Labels
Java AWT Package Example
Java AWT Package Example       In this section you will learn about the AWT package of the Java... as Abstract Window Toolkit (AWT).   What is AWT in java
Image on Frame in Java AWT
Image on Frame in Java AWT       Introduction In this section, you will learn how to display image on the frame. This program shows you how to display image in your application
Different types of event in Java AWT
Different types of event in Java AWT   ... in Java AWT. These are as follows :  ActionEvent AdjustmentEvent... that are generated by your AWT Application. These events are used to make the application more
Create a Frame in Java
in java AWT package. The frame in java works like the main window where your components (controls) are added to develop a application. In the Java AWT, top-level... Create a Frame in Java     
What is AWT in java
What is AWT in java In this Example we will describe awt in java. The awt in java stands for Abstract Windowing Toolkit and is a package... in java full tutorials We have described Interface and Description of AWT Package
How to Create Button on Frame
; frame the topic of Java AWT package. In the section, from the generated output... a command button on the Java Awt Frame. There is a program for the best
Choice Option (Combo) In Java
by using Java AWT package. Here, you will see in the output of the program... of constructing a drop down list in java by using java awt. There is a program... Choice Option (Combo) In Java     
How to handle the text using Key Listener Interface
How to handle the text using Key Listener Interface       In this section, you will learn how to handle the text using the key events on the Java Awt component. All the key events
Hiding Frame in Java
Hiding Frame in Java       Introduction This section illustrates you how to hide the Java Awt frame... object will be visible. By default Java Awt Form is in the invisible state
Radio Button In Java
on the frame. The java AWT , top-level window, are represent by the CheckBoxGroup... for the procedure of inserting checkbox group on the Java AWT frame. Program Description: Here... Radio Button In Java      
How to Create Circle In Java
How to Create Circle In Java       Introduction: This is a simple program of java awt. In this section, you will learn how to create Circle Diagram. The java circle is the most
BorderLayout Example In java
BorderLayout in java awt package. The Border Layout is arranging and resizing components to set in five position which is used in this program. The java program uses... BorderLayout Example In java     
Image Size
; This Java awt (Abstract Windowing Toolkit) tutorial describes about the image size... implementation of awt. The various components are bounded by subclass of Toolkit...:\vinod\awt1>javac C:\vinod\awt1>java ImageSize
Arcs Drawing In Java
Arcs Drawing In Java       Introduction: In this section, you will learn how to create arcs diagram in java awt package. The Java program uses Arcs2D class, arcs2D is the abstract
Events       In this section, you will learn how to handle events in Java awt. Events are the integral part of the java platform. You can see the concepts related to the event
java  what is procedure to run client and server in java(awt
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized


Advertisement null