Share on Google+Share on Google+

srihari badam
Image on frame
0 Answer(s)      4 years and 2 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

Ads

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
image
image   Dear every body please help me how to add and retrive image and video into oracle 11g using jsp
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
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      
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
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
Tutorials   
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? neo4j-server.properties file location SASLError using PLAIN: not-authorized

Ads

 
Advertisement null

Ads