Image on frame

Image on frame

Hi,

This is my code. In this I am unable to load the image.I want to know the problem with this code.

import java.awt.*;
import java.awt.event.*;
public class AwtImg extends Frame
{
    Image img;
    public static void main(String args[])
    {
        AwtImg ai=new AwtImg();
    }
    AwtImg()
    {
        super("Image Frame");
        MediaTracker mt=new MediaTracker(this);
        img=Toolkit.getDefaultToolkit().getImage("swamiji.jpeg");
        mt.addImage(img,0);
        setSize(400,400);
        setVisible(true);
        addWindowListener(new WindowAdapter(){
          public void windowClosing(WindowEvent we){
          dispose();
          }
       });
      }
         public void update(Graphics g){
  paint(g);
  }

  public void paint(Graphics g){
  if(img != null)
  g.drawImage(img, 100, 100, this);
  else
  g.clearRect(0, 0, getSize().width, getSize().height);
  }

}

Thank You

srihari

View Answers









Related Tutorials/Questions & Answers:
Image on frame
Image on frame   Hi, This is my code. In this I am unable to load... java.awt.event.*; public class AwtImg extends Frame { Image img; public...(); } AwtImg() { super("Image Frame"); MediaTracker mt=new
how to set a image in frame? - Swing AWT
how to set a image in frame?  how to set a image in frame using swing
Advertisements
Image on Frame in Java AWT
Image on Frame in Java AWT     ... on the frame. This program shows you how to display image in your application... the image on the frame in your application. These are explained below : ADS
FRAME
FRAME  WHILE I'M RUNNINGFILE OF A GUI PROGRAMME(JDBC CONNECTION) INSTEAD OF OUTPUT FRAME ONLY TWO BLANK FRAMES ARE GETTING DISPLAYD... CAN ANYONE HELP ME TO SOLVE DS PROBLEM
FRAME
FRAME  WHILE I'M RUNNINGFILE OF A GUI PROGRAMME(JDBC CONNECTION) INSTEAD OF OUTPUT FRAME ONLY TWO BLANK FRAMES ARE GETTING DISPLAYD... CAN ANYONE HELP ME TO SOLVE DS PROBLEM
frame
frame  how to creat a frame in java   Hi Friend, Try the following code:ADS_TO_REPLACE_1 import java.awt.*; import javax.swing.*; import java.awt.event.*; class RetrieveDataFromTextFields{ public static void
frame update another frame.
frame update another frame.   How do I make a link or form in one frame update another frame
Frame query
Frame query  Hi, I am working on Images in java. I have two JFrame displaying same image. We shall call it outerFrame and innerFrame.In innerFrame i am rotating the image.After all the rotations i need to display this image
Paint an Image
Paint an Image       This section provides you to paint an image on the frame. Paint means draw an image and set its on the frame to the specified location according to its x
one frame update another frame
one frame update another frame  How do I make a link or form in one frame update another frame
Image Demo
;extends Frame{   Image image;   public static ... Image Demo       This section simply display the image demo that means multiple images and its
panel and frame
panel and frame  What is the difference between panel and frame
Java Frame
Java Frame  What is the difference between a Window and a Frame
image
image  how to add the image in servlet code
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
billing frame
billing frame  how to generate billing frame using swing which contain sr. no, name of product, quantity, price & total
image
image   Dear every body please help me how to add and retrive image and video into oracle 11g using jsp
frame generation
frame generation  Hi I wnat to genarate one frame with two tabs working ,production..and I want two radiobuttons sector ,others in the frames..based on the tab selection I want to clikc the radio button..when i ckick the radio
Frame
frame
Creating a Frame
; Setting the Icon for a Frame    Showing a Dialog Box  ... an Icon to a JButton Component    Making a Frame Non-Resizable    Removing the Title Bar of a Frame   
Image Size
the size of its. For setting an image on the frame, you will need an image that have...;ImageSize extends Frame{   Image image;   public ... Image Size      
how to create frame in swings
how to create frame in swings  how to create frame in swings
collection frame work
collection frame work  explain all the concept in collection frame work
inserting image into database
inserting image into database  how to insert image into database using struts frame work and spring JDBC
link to other frame - Applet
link to other frame  how a button to open to another frame? and the frame can keyin the data and it can show at the previous frame
collection frame work
collection frame work  explain the hierarchy of one dimensional collection frame work classes
collection frame work
collection frame work  could you please tell me detail the concept of collection frame work
Removing the Title Bar of a Frame
. Following  is the image of the frame without title bar: ADS_TO_REPLACE_1 Code... Removing the Title Bar of a Frame   ... bar of a frame or window in java. That means show the frame or window without
ModuleNotFoundError: No module named 'frame'
ModuleNotFoundError: No module named 'frame'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'frame' How to remove the ModuleNotFoundError: No module named 'frame'
Setting the Icon for the frame in Java
the icon of the frame. This program is the detailed illustration to set the icon to the frame. Toolkit class has been used to get the image and then the image... Setting the Icon for the frame in Java   
Setting an Icon for a Frame in Java
an icon for the frame in Java Swing. This program helps us to set the icon (image... the icon for the frame or window after getting the image using the Image class... Setting an Icon for a Frame in Java   
How to design a frame of the picture.
How to design a frame of the picture.       This is a picture frame example, it will help you to make a picture frame easily because it has some simple steps. If you want
single frame coding in java
single frame coding in java  sir, i am a beginner in java.i want to do a desktop application in java in which a single frame satisfies all needs.but i want changes in that frame only.how can i solve this?i think multiple frames
Struts 2 imagae set to frame.
Struts 2 imagae set to frame.  I could not set image to frame...:image src="%{src}" width="150" height="200"/> File Name : <s:property... this: <img:image src=%{src} width="150" height="200"/>, i could
Cross frame menus - Ajax
Cross frame menus  Respected Sir/Madam, I am Ragavendran.R.. I need to implement DHTML Cross frame menus..i.e There must be a page with 2 frames(top and bottom).. The main menus must be in the top frame and when I
spring MVC frame work - Spring
spring MVC frame work  Example of spring MVC frame work
another frame by using awt or swings
another frame by using awt or swings  how to connect one frame to another frame by using awt or swings
Frame with JDBC - JDBC
Frame with JDBC  What is the Frame in JDBC?  Hello,What is the structure of table and in which format you wan't to display the data.Last time also you posted the same question.Answer me the above question and I
Dialog Frame focus - Framework
Dialog Frame focus  Is it possible somehow to focus/activate/select... visit the parent frame also. But on some event(like a button), I want my dialog frame to be focussed/active.(Here i dont want to reopen it. As it is already opened
Iconifying and Maximizing a frame in Java
will be in the minimized form. Following is the image of the frame which has... Iconifying and Maximizing a frame in Java   ... and maximizing a frame in java. Iconifying means to show a frame in minimized
jumping frame jFrame to jInternalframe
jumping frame jFrame to jInternalframe  Afternoon sir, I want to ask something code like jumping frame. example this i have form Login , Menu...) , and in employee(jinternal Frame) have nik(jTexkfield1), name(jtextfield2
swing frame problem
swing frame problem  Hi All, I m creating a swing/awt based window... a frame which have few buttons and Text Box to get some data from user at this time when I will click on submit button then next frame should be open with in same
hibernat frame work
hibernat frame work  what is the deployment structure for 'hibernete.cfg.xml','contact.hbm.xml','Contact.java','FirstExample.java' programs into eclipse ide   Have a look at the following link: Hibernate Tutorial
How to make frame in java
How to make frame in java We are going to discus about frame in java. In this example We have make frame in java Swing. We have created JFrame class... either text, an image, or both. The argument of the constructor is the title
Frame with JDBC - JDBC
Frame with JDBC   i am using frame having two textfield so how i retrieve the data from the ms-access there is two columns name and salary   Hi,Do you want to display the data on JSP Page?If yes then following tutorial
Frame works - Framework
Frame works  I need tutorials on JAVA Plugin Frameworks and hibernate and springs ? I new to these Technologies so i need with Examples to understand Using above technologies i need to do project. so ASAP pls
zend2 frame work
zend2 frame work  Hi can you please detail about Zend framework 2 latest folder structure and related things in details . I already seen zend website am confused with two old and new folder structures which one has to use

Ads