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

Ads









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
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
Advertisements
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 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
; 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...*; public class PaintIcon extends Frame{   Image image
Image Demo
Image Demo       This section simply display the image demo that means multiple images and its name are based on the frame to a particular location. For displaying images demo
billing frame
billing frame  how to generate billing frame using swing which contain sr. no, name of product, quantity, price & total
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
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   
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
Image Size
. For setting an image on the frame, you will need an image that have to be added...;class ImageSize extends Frame{   Image image;  ... Image Size      
Removing the Title Bar of a Frame
. Following  is the image of the frame without title bar: Code Description... Removing the Title Bar of a Frame   ... bar of a frame or window in java. That means show the frame or window without
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
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   
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 an Icon for a Frame in Java
an icon for the frame in Java Swing. This program helps us to set the icon (image... for the frame or window after getting the image using the Image class method named... Setting an Icon for a Frame in Java   
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
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
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
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

Ads