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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


srihari badam
Image on frame
0 Answer(s)      a year and 10 months ago
Posted in : Java Beginners


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


Advertisement
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 :  main
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: import java.awt.*; import javax.swing.*; import java.awt.event.*; class RetrieveDataFromTextFields{ public static void main(String[] args
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
one frame update another frame
one frame update another frame  How do I make a link or form in one frame update another frame
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
Java Frame
Java Frame  What is the difference between a Window and a Frame
panel and frame
panel and frame  What is the difference between panel and frame
billing frame
billing frame  how to generate billing frame using swing which contain sr. no, name of product, quantity, price & total
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
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
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
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   
collection frame work
collection frame work  explain all the concept in collection frame work
how to create frame in swings
how to create frame in swings  how to create frame in swings
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  could you please tell me detail the concept of collection frame work
collection frame work
collection frame work  explain the hierarchy of one dimensional collection frame work classes
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      
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
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
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
Advertisements
 

 

 

DMCA.com