Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


gayathri
java-awt
2 Answer(s)      6 years and 3 months ago
Posted in : Java Beginners



Advertisement
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");


or


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

Prashu
prashobvee@gmail.com


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();
frame.getContentPane().add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,400);
frame.setVisible(true);
}
}

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,

http://www.roseindia.net/java/


Thanks.


Related Tutorials/Questions & Answers:
java awt calender
java awt calender  java awt code for calender to include beside a textfield
JAVA AWT BASE PROJECT
JAVA AWT BASE PROJECT  suggest meaningful java AWT-base project
Advertisements
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
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
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
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 ...so 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, http://www.roseindia.net/java/ 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 ImageSize.java 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
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
java  what is procedure to run client and server in java(awt
 

 

 

DMCA.com