Draw Image on Frame without Graphics

I'm using:
public class Main extends Frame {And I want to draw an image inside the frame WITHOUT{b} using:
java.awt.Graphics;Edited by: Nickasaur on Aug 28, 2009 4:25 PM

There´s a tutorial on that matter here .
But for the beginning, it might be helpful for you to know that you can at any time call the getGraphics() Method of any child of java.awt.Component to get its Graphics object. Still, I´m not sure if that is good practice.
I´d take the tutorial if I were you.
Edited by: anotherAikman on Aug 28, 2009 4:45 PM

Similar Messages

  • How draw image into frame in applet

    How draw image into frame in applet.Please give my simple example code.

    http://search.java.sun.com/search/java/index.jsp?qt=%2Bdraw+%2Bimage+%2Bpanel+%2Bhow&nh=10&qp=&rf=1&since=&country=&language=&charset=&variant=&col=javaforums

  • Draw Image out of paint(graphics) method

    Does anybody know who can I draw an image out of the paint method of the component??
    thx

    Create a BufferedImage, get it's graphics and draw on this image as much as you want.
    BufferedImage bI = new BufferedImage(200,200,BufferedImage.TYPE_3BYTE_BGR);
    Graphics      g  = bI.getGraphics();
    Graphics2D    g2 = bI.createGraphics();
    g.setColor(Color.red);
    g.drawLine(10,10,190,190);
    g2.setColor(Color.blue);
    g2.draw(new Rectangle(50,50,100,100));

  • Drawing image Urgent!

    hai Guys!
    is it possible to draw image in xor mode using drawregion or drawimage if yes then how it can be done!

    hi frens..
    Is there way of drawing an image on Frame
    without erasing previous image. Each time the
    repaint() is called for drawing new image on frame
    using Graphics object, repaint() just clears the
    previous images , but i want previous image to be
    sustained .
    ImageIcon WhiteIcon = new ImageIcon("White.GIF");
    JL = new JLabel(null ,WhiteIcon, 0 );
    f.add(JL);Hope this will do.

  • After a few minutes on certain websites, firefox stops drawing new frames without a mouse movement to force a redraw

    After having certain pages open for between 5-15 minutes (at the most) such as youtube, facebook, or myspace (these are the sites that consistently cause it, but are not limited to them.) The browser no longer draws new frames without the mouse being moved and calling the draw function through it.
    The issue started a month or two ago. There had been no new plugins or add-ons installed for at least another month prior.
    The closing X in the top right also becomes non responsive (though it will light up.) The browser can be closed through the right click menu in the task bar, along with the closing X in the thumbnail preview.
    Program and window completely freeze when attempting to move the window for around 10 seconds, then move to the location designated.
    Other browser have no issues.
    system: Windows 7 Ultimate 64 bit.
    6GB RAM 1600Mhz
    core i7 920
    1.5TB free space in C drive
    currently installed plug-ins are:
    Acrobat 9.3.0.148
    Java Deployment Toolkit 6.0.210.7
    Java Platform SE 6 U21 6.0.210.7
    Mozilla Default Plug-in 1.0.0.15 (disabled)
    Shockwave Flash 10.0.45.2
    Shockwave for Director 11.5.7.609
    Silverlight 3.0.50106.0
    Unity Player 2.6.1.31.223 (disabled)
    Windows Live Photo Gallery 14.0.8081.709 (disabled)
    Yahoo Application State Plugin 1.0.0.7 (disabled)
    Extensions:
    AVG Safe Search 9.0.0.855
    AVG Security Toolbar 4.002.023.004
    Java Console 6.0.18 (disabled)
    Java Console 6.0.21
    StumbleUpon 3.73
    XULRunner 1.9.1 (disabled)
    Zynga Toolbar 2.7.1.3 (disabled)
    Only default Theme installed.

    Podcast (original): http://council.cio.com/podcast/temp.mp3
    Podcast (re-encoded by iTunes): http://council.cio.com/podcast/temp3.mp3
    Music MP3s that aren't working for me:
    http://council.cio.com/podcast/findyouregone.mp3
    http://council.cio.com/podcast/findyourehere.mp3
    http://council.cio.com/podcast/youvideoversion.mp3
    Music MP3 that is working:
    http://council.cio.com/podcast/twoareone.mp3
    (Oh, and ignore my comment earlier that this mp3 stopped working. I got confused back there with all the various tests... This file does play fully. The player also waits until the file is fully downloaded before starting to play... As opposed to the others where the player starts and ends playing before they are downloaded completely.)

  • Graphics refuses to draw Images

    I was attempting to make an applet today, but for some reason, I can't draw Images. I had a little program going, but I decided to make this basic test applet to see if Images would draw at all.
    import java.awt.*;
    import java.applet.*;
    public class TestApplet extends Applet
         Image im;
         public void init()
              setSize(300, 400);
              im = getImage(getDocumentBase(), "Picture.GIF");
         public void start()
              repaint();
         public void paint(Graphics g)
              g.drawImage(im, 10, 10, this);
              g.drawString("I can draw a string", 10, 10);
         public void stop()
         public void destroy()
    }The string gets drawn fine, but the image just refuses to show up. Any idea why?
    Message was edited by:
    Guest42

    //  <applet code="TestApplet" width="300" height="400"></applet>
    import java.awt.*;
    import java.applet.*;
    public class TestApplet extends Applet
         Image im;
        public void init()
            setSize(300, 400);
            im = getImage(getDocumentBase(), "Picture.GIF");
            loadImage();
        private void loadImage()
            MediaTracker tracker = new MediaTracker(this);
            tracker.addImage(im, 0);
            try
                tracker.waitForID(0);
            catch(InterruptedException ie)
                System.err.println("interrupt: " + ie.getMessage());
            int status = tracker.statusID(0, false);
            String results = "";
            if((status & MediaTracker.COMPLETE) == MediaTracker.COMPLETE)
                results += "COMPLETE";
            if((status & MediaTracker.ABORTED) == MediaTracker.ABORTED)
                results += "ABORTED";
            if((status & MediaTracker.ERRORED) == MediaTracker.ERRORED)
                results += "ERRORED";
            System.out.println("results = " + results);
        public void start()
    //        repaint();
        public void paint(Graphics g)
            g.drawImage(im, 10, 10, this);
            g.drawString("I can draw a string", 10, 10);
        public void stop()
        public void destroy()
    }

  • Problems drawing images form another class

    Ok as the title says I'm having trouble drawing images from a different class. I have a class that represents a plane and it has a draw' method that draws its .gif image.
    public void draw (Graphics g)
    g.drawImage(planepic , xPos, yPos, null)
    then in my main class in the paint method i have
    plane.draw(g);
    I think my problem is the null for my image observer. I tried using null as my image observer and i got a error saying i can't make a static reference to a non static method.
    I've done some research because i never really understood static but i still don't quite get it.
    Also when I use this as my image observer i get a error in my plane object.
    I also just tried passing and making a object for my main class and i still got the static error.
    Any help is appreciated and thanks in advance

    Ok as the title says I'm having trouble drawing
    images from a different class. I have a class that
    represents a plane and it has a draw' method that
    draws its .gif image.
    public void draw (Graphics g)
    g.drawImage(planepic , xPos, yPos, null)
    in my main class in the paint method i have
    plane.draw(g);
    I think my problem is the null for my image observer.
    I tried using null as my image observer and i got a
    error saying i can't make a static reference to a non
    static method. Use a minimal implementation of the ImageObserver to be sure.
    public class Plane implements ImageObserver
    public boolean imageUpdate(
    Image img,int infoFlags,int x,int y,int width,int height)
       switch(infoFlags)
          case ALLBITS:
                    return false;
          case SOMEBITS:
                    return true;
          default:
                return true;
    I've done some research because i never really
    understood static but i still don't quite get it.
    Also when I use this as my image observer i get a
    error in my plane object.
    I also just tried passing and making a object for my
    main class and i still got the static error.
    Any help is appreciated and thanks in advanceWhen you call draw(g) from your other class you hand it a Graphics context that you instantiated somewhere else ie: in another class. Without a more complete example it is really impossible to determine your issue for sure,
    but if I was to guess I would say you need to make sure that the Graphics context handed to the draw(Graphics) method was instantiated from a Component that was already visible. ie: Do a f
    Frame.createImage() from your parent frame after iyou have already called setVisible(true); In other words I suspect you are making and Image from some other Component that is not yet visible. That however is a guess so if not the issue post the rest of the code or at least a minimal implementation that demonstrates this.
    About static:
    static means the class/variable is the same throughout ALL classes of that type and if changed in one instance it will change and thus be the same for all instances.
    You CAN call static by referencing the base class Object without having to instantiate.
    ie:given
    public class SomeClass
    static String name;
    static String getName
       if(name == null)
          name = "DefaultName";
       return name;
    }Thus you could call..
      String name = SomeClass.getName();As opposed to
    SomeClass myClass = new SomeClass();
          myClass.getName();This can get you in trouble if you try to make a method that is static
    that then tries to reference non static variables.
    ie:
    public class SomeClass
    int x;
    static String name;
    SomeClass()
       x=0;
    static String getName
       if(name == null)
          name = "DefaultName";
       x++;
       return name;
    }In this case SomeClass.getName(); will throw and exception because it is trying to access[b] x  from a static context .
    Hope that clears that up for you; if not post a more complete example.
    Good Luck!
    (T)

  • Drawing images in JComponent

    Hi,
    I have an application laid out as Figure 1 depicts.
    JFrame
    |
    | JMenuBar
    |-----------------------------------------
    | ------------------JPanel - appPanel
    | |--------------------------------|
    | | ---|------------------ JPanel - displayPanel
    | | | |
    | |----------------|---------------|
    | |-------------------------- JComponent - jcanvas
    |
    | |--------------------------------|
    | | ----|----------------------- JPanel - controlPanel
    | | |
    | |--------------------------------|
    |
    |--------------------------------------------
    Figure 1
    The problem I am having is that:
    theJPanel (appPanel) contains two JPanels (displayPanel and controlPanel) and I am adding a JComponent called JCanvas
    to the displayPanel and I use it to draw images on it of type BufferedImage. Now, the image is displayed without any problem
    but when I resize the application (JFrame) I lose my image. I know the JCanvas (JComponent) is being redrawn because I can
    temporarily see the image but something is overwriting the image. I have set appPanel, displayPanel, controlPanel to opaque
    but I still loose the image.
    Of point maybe, if I access the JMenuBar the image will appear less what part of the menu bar obscures it.
    The appPanel, controlPanel, and displayPanel are created in the IDE. Where as, the JCanvas is a seperate class extending JCompoment
    and it has it own paintComponent method to do the image rendering and is added to the displayPanel when instantiated.
    What I don't understand is why isn't the image staying visible after a frame resize?
    Thanks,
    Bob

    Hopefully this will fit.
    You will have to provide your own image file.
    * SwingPaintDemo2.java
    * Created on Sep 27, 2008, 10:57:22 AM
    * Company: 
    * Copyright: Sep 27, 2008
    * Version:
    import javax.swing.SwingUtilities;
    import javax.swing.JFrame;
    import javax.swing.BorderFactory;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.imageio.ImageIO;
    import javax.swing.JComponent;
    * @author
    public class SwingPaintDemo2 {
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
        private static void createAndShowGUI() {
            System.out.println("Created GUI on EDT? " +
                SwingUtilities.isEventDispatchThread());
            JFrame f = new JFrame("Swing Paint Demo");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(new MyPanel());
            f.pack();
            f.setVisible(true);
    class MyPanel extends JComponent {
        BufferedImage bi;
        File file;
        Dimension d = new Dimension();
        boolean fullScreen = false;
        public MyPanel() {
            setBorder(BorderFactory.createLineBorder(Color.black));
            file = new File("g://java/images/dido_img.jpg");
            try {
                bi = ImageIO.read(file);
            } catch (IOException ex) {
                Logger.getLogger(MyPanel.class.getName()).
                    log(Level.SEVERE, null, ex);
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(350, 350);
        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D) this.getGraphics();
            d = this.getPreferredSize();
            if (d.width == 0 || d.height == 0) {/* error */
            if (!fullScreen) {
                int px = (d.width - bi.getWidth()) / 2;
                int py = (d.height - bi.getHeight()) / 2;
                g2.drawImage(bi, null, px, py);
            } else {
                g2.drawImage(bi, 0, 0, d.width, d.height,
                    0, 0, bi.getWidth(), bi.getHeight(), null);
    }

  • Draw image over Swing to mask.

    I have a window and I've overridden it make it draw all of it's components and then draw images over them (on a back buffer and then flip so the swing shouldn't ever be seen).
    It works perfectly and the swing components (JButtons and the like) catch the clicks when I click on the images masking them. The problem is when I click them for a very brief moment I see the Swing component come through. How is Swing doing this? Since I blt in a specific order and then flip. Somehow it is using the Graphics for the window directly - I overrode invalidate in a few ways but that just broke the components altogether.
    Anyone masked Swing components with images using a BufferStrategy? I would love some advice.

    AbstractButton (which JButton extends) calls JComponent.paintImmediately upon a click, so I don't think you can stop it without overriding AbstractButton and JButton (not recommended).
    Either override the paint method for your components to look like your overlaid image or remove your Swing components and test the mouse click location in the MouseListener.
    --Jon

  • I need help to draw in a frame, please

    Hi Im new to java and I need some help to draw a rainbow in a frame. I already made the frame , but i dont know how to draw inside the frame.
    here is my code so far:
    import java.awt.*;
    import javax.swing.*;
    public class Regnbue {
         public static void main(String[]args){
              JFrame ramme = new JFrame();
              ramme.setSize(600,300);
              Container cp = ramme.getContentPane();
              cp.setBackground(Color.white);
              ramme.setVisible(true);
    any help to finish this simple draw would be nice!!
    thanx

    I forgot , here is my code so far :
    import java.awt.*;
    import javax.swing.*;
    public class Regnbue {
         public static void main(String[]args){
              Rainbowpanel r= new Rainbowpanel();// her is where i make
    // my frame I think.
              JFrame ramme = new JFrame();
              ramme.setSize(600,300);
              Container cp = ramme.getContentPane();
              cp.setBackground(Color.white);
              ramme.setVisible(true);
    class Rainbowpanel extends JPanel {
         public void paintComponent(Graphics g) {// this is the part that I
    // dont understand, how can I put the arc into the container above??
              super.paintComponent(g);
              g.fillArc(5, 5, 10, 50, 0, 180);
         thanks
    elektropan

  • How can I draw image in a vbean?

    How can I draw image in a vbean?
    this is my code :
    import java.awt.BorderLayout;
    import java.awt.Image;
    import java.awt.Graphics;
    import java.net.MalformedURLException;
    import java.net.URL;
    import com.sun.jimi.core.Jimi;
    import oracle.forms.handler.IHandler;
    import oracle.forms.properties.ID;
    import oracle.forms.ui.VBean;
    public class PrintEmailLogo extends VBean {
         URL url;
         Image img;
         boolean ImageLoaded = false;
         public void paint(Graphics g) {
              if (ImageLoaded) {
                   System.out.println("yes~~~");
                   g.drawImage(img, 0, 0, null);
              } else
                   System.out.println("no~~~");
         public boolean imageUpdate(Image img, int infoflags, int x, int y, int w,
                   int h) {
              if (infoflags == ALLBITS) {
                   System.out.println("yes");
                   ImageLoaded = true;
                   repaint();
                   return false;
              } else
                   return true;
         public void init(IHandler arg0) {
              super.init(arg0);
              try {
                   url = new URL("file:print/77G.gif");
                   img = Jimi.getImage(url);
                   Image offScreenImage = createImage(size().width, size().height);
                   Graphics offScreenGC = offScreenImage.getGraphics();
                   System.out.println(offScreenGC.drawImage(img, 0, 0, this));
              } catch (MalformedURLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    but when I run it in forms
    when it run Graphics offScreenGC = offScreenImage.getGraphics();
    It throw a exception:
    java.lang.NullPointerException     at com.avicit.aepcs.calendar.PrintEmailLogo.init(PrintEmailLogo.java:72)     at oracle.forms.handler.UICommon.instantiate(Unknown Source)     at oracle.forms.handler.UICommon.onCreate(Unknown Source)     at oracle.forms.handler.JavaContainer.onCreate(Unknown Source)     at oracle.forms.engine.Runform.onCreateHandler(Unknown Source)     at oracle.forms.engine.Runform.processMessage(Unknown Source)     at oracle.forms.engine.Runform.processSet(Unknown Source)     at oracle.forms.engine.Runform.onMessageReal(Unknown Source)     at oracle.forms.engine.Runform.onMessage(Unknown Source)     at oracle.forms.engine.Runform.processEventEnd(Unknown Source)     at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)     at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)     at java.awt.Component.dispatchEventImpl(Unknown Source)     at java.awt.Container.dispatchEventImpl(Unknown Source)     at java.awt.Component.dispatchEvent(Unknown Source)     at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)     at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)     at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)     at java.awt.Container.dispatchEventImpl(Unknown Source)     at java.awt.Component.dispatchEvent(Unknown Source)     at java.awt.EventQueue.dispatchEvent(Unknown Source)     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)     at java.awt.EventDispatchThread.run(Unknown Source)
    I change it to:
    import java.awt.BorderLayout;
    import java.awt.Image;
    import java.awt.Graphics;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.swing.JFrame;
    import com.sun.jimi.core.Jimi;
    import oracle.forms.handler.IHandler;
    import oracle.forms.properties.ID;
    import oracle.forms.ui.VBean;
    public class PrintEmailLogo extends VBean {
         URL url;
         Image img;
         public void paint(Graphics g) {
              try {
                   url = new URL("file:print/77G.gif");
                   img = Jimi.getImage(url);
                   g.drawImage(img, 0, 0, this));
              } catch (MalformedURLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public void init(IHandler arg0) {
              super.init(arg0);
    But it display nothing.
    It isn't paint continuous.
    what's wrong in my vbean?
    please help me.

    The following code works fine for me:
    package oracle.forms.fd;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import oracle.forms.handler.IHandler;
    import oracle.forms.properties.ID;
    import oracle.forms.ui.CustomEvent;
    import oracle.forms.ui.VBean;
    public class test extends VBean {
      private URL url;
      private URL m_codeBase; 
      private Image img;
    public void paint(Graphics g) {
      // draw the image
      g.drawImage(img, 0, 0, this);
    public void init(IHandler arg0) {
       super.init(arg0);
       // load image file
       img = loadImage("file:///c:/coyote.jpg");   
    public test()
        super();
       *  Load an image from JAR file, Client machine or Internet URL  *
      private Image loadImage(String imageName)
        URL imageURL = null;
        boolean loadSuccess = false;
        Image img = null ;
        //JAR
        imageURL = getClass().getResource(imageName);
        if (imageURL != null)
          try
            img = Toolkit.getDefaultToolkit().getImage(imageURL);
            loadSuccess = true;
            return img ;
          catch (Exception ilex)
            System.out.println("Error loading image from JAR: " + ilex.toString());
        else
          System.out.println("Unable to find " + imageName + " in JAR");
        //DOCBASE
        if (loadSuccess == false)
          System.out.println("Searching docbase for " + imageName);
          try
            if (imageName.toLowerCase().startsWith("http://")||imageName.toLowerCase().startsWith("https://"))
              imageURL = new URL(imageName);
            else if(imageName.toLowerCase().startsWith("file:"))
              imageURL = new URL(imageName);
            else
              imageURL = new URL(m_codeBase.getProtocol() + "://" + m_codeBase.getHost() + ":" + m_codeBase.getPort() + imageName);
            System.out.println("Constructed URL: " + imageURL.toString());
            try
              img = createImage((java.awt.image.ImageProducer) imageURL.getContent());
              loadSuccess = true;
              System.out.println("Image found: " + imageURL.toString());
              return img ;
            catch (Exception ilex)
              System.out.println("Error reading image - " + ilex.toString());
          catch (java.net.MalformedURLException urlex)
            System.out.println("Error creating URL - " + urlex.toString());
        //CODEBASE
        if (loadSuccess == false)
          System.out.println("Searching codebase for " + imageName);
          try
            imageURL = new URL(m_codeBase, imageName);
            System.out.println("Constructed URL: " + imageURL.toString());
            try
              img = createImage((java.awt.image.ImageProducer) imageURL.getContent());
              loadSuccess = true;
              System.out.println("Image found: " + imageURL.toString());
              return img ;
            catch (Exception ilex)
                    System.out.println("Error reading image - " + ilex.toString());
          catch (java.net.MalformedURLException urlex)
            System.out.println("Error creating URL - " + urlex.toString());
        if (loadSuccess == false)
          System.out.println("Error image " + imageName + " could not be located");
        return img ;
    }Francois

  • How to change the image in SAP network graphics

    In my development with SAP network graphics, I found it difficult to change the image displayed in SAP network graphics. and i define the image path in IMG, it doesn't work. Is there any one who can tell me how to diplay a image in SAP network graphics. In my program the class cl_gui_netchart is used. 
    Thanks a lot!

    hi,
    JFrame frame;
    frame.setVisible(true);
    frame.setIconImage(new ImageIcon("icons/img007.gif").getImage());
    frame.setSize(800,600);
    i think the thing u r searching is :
    frame.setIconImage(new ImageIcon("icons/img007.gif").getImage());
    ~~~radha

  • Creating a still frame without timex

    Hi, I'm wondering if there is a really quick way to create a still frame without using timex (it freezes up my entire tree for some reason when I use it with the keymix layer), without having to render out a single image (I dont want to loose quality) and without having to drag it through timeview (I get real finicky trying to drag the time bar back and forth with the mouse or pen)?
    There has got to be an easy way!

    Just change it from 1145-1325 to 1-5000 or something(you are allowed to change those values). Either that or do a new filein and only pick the frame you need, not the entire frame sequence and it will automatically set the in and out as infinity(uncheck the "sequence listing" in the file browser).

  • Putting image on Frame in netbeans

    Dear All
    How can we add an image on frame in netbeans IDE.
    From
    Rajeev Sarawat

    you have to create one class in the same project for the main panel(name it as MyPanel) then go to "customize code" of main panel and instead of default creation do custom creation of the main panel.
    here is the code for MyPanel----
    import java.awt.Color;
    import java.awt.Dimension;
    import javax.swing.*;
    import java.awt.image.*;
    import javax.imageio.*;
    import java.awt.Graphics;
    import java.io.IOException;
    import java.io.File;
    * @author Administrator
    class MyPanel extends JPanel {
    BufferedImage image;
    String file;
    public MyPanel(String s) {
    setBorder(BorderFactory.createLineBorder(Color.black));
    file = s;
    public Dimension getPreferredSize() {
    return new Dimension(711,360);
    protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    try
    image = ImageIO.read(new File(file));
    }catch(IOException e)
    System.out.println(e);
    int w = image.getWidth(null);
    int h = image.getHeight(null);
    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    g.drawImage(image, 10, 20, null);
    i think it would be helpful

  • Add image map to layer graphic?

    There is no allowance for image maps on the Properties menu when a graphic placed in a layer is selected.
    I have as US map within a <div> layer for exact placement.  But I want to draw image maps for each state.
    How can I do that?

    There is no allowance for image maps on the Properties menu when a graphic placed in a layer is selected.
    Whether or not your image is within a layer, a table, a span, or any page container would not affect your ability to add an image map to it.
    I have as US map within a <div> layer for exact placement.
    It is not necessary to use 'layers' to achieve exact placement, but as stated above, the image's container is immaterial to the use of image maps.  What I suspect is happening is that you are trying to do this on a template controlled child page - is that correct?

Maybe you are looking for