JApplet Image Buttons not init().

I have created a JApplet where it contains image buttons. When I run the applet in a web page I get an error message, not inialised.
I have been informed that the reason is the image buttons. Does the getCodeBase() method form part of the solution and if so does anyone know how.
I have been going mad trying to find a solution.
Thanks

I have created a JApplet where it contains image buttons. When I run the applet in a web page I get an error message, not inialised.
I have been informed that the reason is the image buttons. Does the getCodeBase() method form part of the solution and if so does anyone know how.
I have been going mad trying to find a solution.
Thanks

Similar Messages

  • Image Buttons Not Showing Up

    Can someone help me out. My image buttons are not showing up until after I mouse over them. Any help or responses is appreciated.
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.util.Vector;
    import java.lang.Math;
    import javax.swing.*;
    public class PokerApp extends JApplet
    implements MouseListener, MouseMotionListener, ActionListener, ItemListener
    // -------------- Global Variables ------------------------
    int width, height;
    int mx, my; // the mouse coordinates
    Color bgc = Color.lightGray;
    Color fgc = Color.black;
    Checkbox players[] = new Checkbox[10];
    CheckboxGroup cbg;
    Image img;
    public void init() {
    width = getSize().width;
    height = getSize().height;
    setBackground(bgc);
    setForeground(fgc);
    String s1;
    boolean sel;
    JButton jb;
    Container contentPane = getContentPane();
    contentPane.setLayout(null);
    ImageIcon iic[] = new ImageIcon[13];
    cbg = new CheckboxGroup();
    for (int i=0; i<9; ++i) {
    s1 = Integer.toString(i+2);
    sel = (i == 7);
    players[i] = new Checkbox(s1, cbg, sel);
    players.setBackground(bgc);
    players[i].setForeground(fgc);
    players[i].setName(s1);
    // setBounds (x=hor, y=ver, wid, hgt)
    players[i].setBounds(80 + i*30, 5, 30, 20);
    contentPane.add(players[i]);
    players[i].addItemListener(this);
    for (int i=0; i<13; ++i) {
    img = getImage(getDocumentBase(), "images/v" + (i+1) + ".jpg");
    iic[i] = new ImageIcon(img);
    jb = new JButton(iic[i]);
    jb.addActionListener(this);
    jb.setBounds(i*30, 30, 30, 30);
    contentPane.add(jb);
    img = getImage(getDocumentBase(), "images/v2.jpg");
    ImageIcon tmp = new ImageIcon(img);
    jb = new JButton(tmp);
    jb.addActionListener(this);
    jb.setBounds(200, 200, 30, 30);
    jb.setVisible(true);
    contentPane.add(jb);
    jb.validate();
    addMouseListener( this );
    addMouseMotionListener( this );
    public void start() {
    // start or resume exectuion
    public void stop() {
    // suspends execution
    public void destroy() {
    // perform shutdown activites
    public void paint( Graphics g) {
    width = getSize().width;
    height = getSize().height;
    Font font1 = new Font("Ariel", Font.PLAIN, 11);
    g.setFont(font1);
    g.setColor( Color.red );
    g.drawRect(0, 0, (width - 1), 30);
    g.drawString( "Beginning", 5, 12);
    g.drawString( "# of Players", 5, 24);
    public void mouseEntered( MouseEvent me ) { }
    public void mouseExited( MouseEvent me ) { }
    public void mousePressed( MouseEvent me ) { }
    public void mouseReleased( MouseEvent me ) { }
    public void mouseClicked( MouseEvent me ) { }
    public void mouseDragged( MouseEvent e ) { }
    public void mouseMoved( MouseEvent e ) { }
    public void actionPerformed (ActionEvent ae) { }
    public void itemStateChanged(ItemEvent ie) { }

    The part you are missing is a call to super.paint in your paint method
        public void paint( Graphics g) {
            super.paint(g);
            ...This tells the component (the JApplet) to do its default rendering before it does the custom rendering in the paint method. So the component will render your buttons before it does the rest of the paint code.
    I also added an image loading method to your applet:
    //  <applet code="PA" width="400" height="400"></applet>
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.util.Vector;
    import java.lang.Math;
    import javax.swing.*;
    public class PA extends JApplet implements MouseListener, MouseMotionListener,
                                               ActionListener, ItemListener
        // -------------- Global Variables ------------------------
        int width, height;
        int mx, my;                             // the mouse coordinates
        Color bgc = Color.lightGray;
        Color fgc = Color.black;
        Checkbox players[] = new Checkbox[10];
        CheckboxGroup cbg;
    //    Image img;
        Font font1;
        public void init() {
            // only need to create a font one time, not with every paint call
            font1 = new Font("Ariel", Font.PLAIN, 11);
            width = getSize().width;
            height = getSize().height;
            setBackground(bgc);
            setForeground(fgc);
            String s1;
            boolean sel;
            JButton jb;
            Container contentPane = getContentPane();
            contentPane.setLayout(null);
    //        ImageIcon iic[] = new ImageIcon[13];
            cbg = new CheckboxGroup();
            for (int i=0; i<9; ++i) {
                s1 = Integer.toString(i+2);
                sel = (i == 7);
                players[i] = new Checkbox(s1, cbg, sel);
                players.setBackground(bgc);
    players[i].setForeground(fgc);
    players[i].setName(s1);
    // setBounds (x=hor, y=ver, wid, hgt)
    players[i].setBounds(80 + i*30, 5, 30, 20);
    contentPane.add(players[i]);
    players[i].addItemListener(this);
    Image[] images = loadImages();
    for(int j = 0; j < images.length; j++)
    ImageIcon icon = new ImageIcon(images[j]);
    JButton b = new JButton(icon);
    b.addActionListener(this);
    b.setBounds(j*30, 30, 30, 30);
    contentPane.add(b);
    Image image = getImage(getDocumentBase(), "images/v2.jpg");
    ImageIcon tmp = new ImageIcon(image);
    jb = new JButton(tmp);
    jb.addActionListener(this);
    jb.setBounds(200, 200, 30, 30);
    jb.setVisible(true);
    contentPane.add(jb);
    // jb.validate();
    addMouseListener( this );
    addMouseMotionListener( this );
    private Image[] loadImages()
    MediaTracker tracker = new MediaTracker(this);
    Image[] images = new Image[13];
    for (int j = 0; j < images.length; j++) {
    images[j] = getImage(getDocumentBase(), "images/v" + (j + 1) + ".jpg");
    tracker.addImage(images[j], 0);
    try
    tracker.waitForAll();
    catch(InterruptedException ie)
    System.err.println("tracker interrupt: " + ie.getMessage());
    return images;
    public void start() {
    // start or resume exectuion
    public void stop() {
    // suspends execution
    public void destroy() {
    // perform shutdown activites
    public void paint( Graphics g) {
    super.paint(g);
    width = getSize().width;
    height = getSize().height;
    g.setFont(font1);
    g.setColor( Color.red );
    g.drawRect(0, 0, (width - 1), 30);
    g.drawString( "Beginning", 5, 12);
    g.drawString( "# of Players", 5, 24);
    public void mouseEntered( MouseEvent me ) { }
    public void mouseExited( MouseEvent me ) { }
    public void mousePressed( MouseEvent me ) { }
    public void mouseReleased( MouseEvent me ) { }
    public void mouseClicked( MouseEvent me ) { }
    public void mouseDragged( MouseEvent e ) { }
    public void mouseMoved( MouseEvent e ) { }
    public void actionPerformed (ActionEvent ae) { }
    public void itemStateChanged(ItemEvent ie) { }

  • Spry Image button not working on IE

    Hi,
    I have a image button on a spry menu that displays fine in firefox and safari, but not in IE. It is just opaque on the menu buttons to the page background.
    It's a personal site for a wedding that i need to go live with in a week or so,I can't figure out what I'm doing wrong so hope someone can help.
    site is here
    @charset "UTF-8";
    /* SpryMenuBarHorizontal.css - version 0.6 - Spry Pre-Release 1.6.1 */
    /* Copyright (c) 2006. Adobe Systems Incorporated. All rights reserved. */
    LAYOUT INFORMATION: describes box model, positioning, z-order
    /* The outermost container of the Menu Bar, an auto width box with no margin or padding */
    ul.MenuBarHorizontal
        margin: 0;
        padding: 0;
        list-style-type: none;
        font-size: 100%;
        cursor: default;
        width: auto;
    /* Set the active Menu Bar with this class, currently setting z-index to accomodate IE rendering bug: http://therealcrisp.xs4all.nl/meuk/IE-zindexbug.html */
    ul.MenuBarActive
        z-index: 1000;
    /* Menu item containers, position children relative to this container and are a fixed width */
    ul.MenuBarHorizontal li
        margin: 0;
        padding: 0;
        list-style-type: none;
        font-size: 100%;
        position: relative;
        text-align: center;
        cursor: pointer;
        width: 130px;
        float: left;
        background-image: url(../images/Button3.jpg);
        font-weight: bolder;
        background-color: transparent;
    /* Submenus should appear below their parent (top: 0) with a higher z-index, but they are initially off the left side of the screen (-1000em) */
    ul.MenuBarHorizontal ul
        margin: 0;
        padding: 0;
        list-style-type: none;
        font-size: 100%;
        z-index: 1020;
        cursor: default;
        width: 8.2em;
        position: absolute;
        left: -1000em;
    /* Submenu that is showing with class designation MenuBarSubmenuVisible, we set left to auto so it comes onto the screen below its parent menu item */
    ul.MenuBarHorizontal ul.MenuBarSubmenuVisible
        left: auto;
    /* Menu item containers are same fixed width as parent */
    ul.MenuBarHorizontal ul li
        width: 8.2em;
    /* Submenus should appear slightly overlapping to the right (95%) and up (-5%) */
    ul.MenuBarHorizontal ul ul
        position: absolute;
        margin: -5% 0 0 95%;
    /* Submenu that is showing with class designation MenuBarSubmenuVisible, we set left to 0 so it comes onto the screen */
    ul.MenuBarHorizontal ul.MenuBarSubmenuVisible ul.MenuBarSubmenuVisible
        left: auto;
        top: 0;
    DESIGN INFORMATION: describes color scheme, borders, fonts
    /* Submenu containers have borders on all sides */
    ul.MenuBarHorizontal ul
        border: 1px solid #CCC;
    /* Menu items are a light gray block with padding and no text decoration */
    ul.MenuBarHorizontal a
        display: block;
        cursor: pointer;
        padding: 0.5em 0.75em;
        color: #333;
        text-decoration: none;
    /* Menu items that have mouse over or focus have a blue background and white text */
    ul.MenuBarHorizontal a:hover, ul.MenuBarHorizontal a:focus
        background-color: #A1E63D;
        color: #FFF;
        font-weight: bold;
    /* Menu items that are open with submenus are set to MenuBarItemHover with a blue background and white text */
    ul.MenuBarHorizontal a.MenuBarItemHover, ul.MenuBarHorizontal a.MenuBarItemSubmenuHover, ul.MenuBarHorizontal a.MenuBarSubmenuVisible
        background-color: #B3EE5C;
        color: #009;
        font-weight: bold;
    SUBMENU INDICATION: styles if there is a submenu under a given menu item
    /* Menu items that have a submenu have the class designation MenuBarItemSubmenu and are set to use a background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal a.MenuBarItemSubmenu
        background-image: url(SpryMenuBarDown.gif);
        background-repeat: no-repeat;
        background-position: 95% 50%;
    /* Menu items that have a submenu have the class designation MenuBarItemSubmenu and are set to use a background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal ul a.MenuBarItemSubmenu
        background-image: url(SpryMenuBarRight.gif);
        background-repeat: no-repeat;
        background-position: 95% 50%;
    /* Menu items that are open with submenus have the class designation MenuBarItemSubmenuHover and are set to use a "hover" background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal a.MenuBarItemSubmenuHover
        background-image: url(SpryMenuBarDownHover.gif);
        background-repeat: no-repeat;
        background-position: 95% 50%;
    /* Menu items that are open with submenus have the class designation MenuBarItemSubmenuHover and are set to use a "hover" background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal ul a.MenuBarItemSubmenuHover
        background-image: url(SpryMenuBarRightHover.gif);
        background-repeat: no-repeat;
        background-position: 95% 50%;
    BROWSER HACKS: the hacks below should not be changed unless you are an expert
    /* HACK FOR IE: to make sure the sub menus show above form controls, we underlay each submenu with an iframe */
    ul.MenuBarHorizontal iframe
        position: absolute;
        z-index: 1010;
        filter:alpha(opacity:0.1);
    /* HACK FOR IE: to stabilize appearance of menu items; the slash in float is to keep IE 5.0 from parsing */
    @media screen, projection
        ul.MenuBarHorizontal li.MenuBarItemIE
            display: inline;
            f\loat: left;
            background: #FFF;

    Sorry, but I do not see that you have added the code. Not only that, I think I may have made a boo-boo by saying that the background-image should be modified. The original says
    /* HACK FOR IE: to stabilize appearance of menu items; the slash in float is to keep IE 5.0 from parsing */
    @media screen, projection
    ul.MenuBarHorizontal li.MenuBarItemIE
    display: inline;
    f\loat: left;
    background: #FFF;
    so that background should contain the image, not background-image.
    Gramps

  • Image Buttons Not Working in IE10 Normal Mode

    Hi Team,
    Greetings of the Day!! We are supporting a project which included the technologies "ADF , BPEL , AIA , SOA".
    We have a page developed in ADF and the page contains TABS.
    We have a LOV which have 'Add Product' as one of the value.
    When we click try to Configure the Line for a particular Product it is redirecting dmz-server where we have 'YES/NO' Buttons but this buttons are not working in IE-10 Normal mode and in other browsers buttons are working fine.
    Could some one please help me on this.
    Thanks

    For that matter, the "return to menu" which is set to a Main button type, isn't working either.  that is one of the three.  After i had removed the damaged button and copied it from another it worked.  Then i simply edited the text of a different button (mind you one that still works) and the "return to menu" quit along with the bottom 2 buttons.  I just can't figure it out.  I have shut the app down and restarted and nothing seems to be working

  • Upgrading APEX from 3.2 to 4.0 images and buttons not displaying correctly

    Database 11.2.0.1
    APEX: 3.2.1
    Attemping to upgrade APEX from 3.2 to 4.0. The installation script runs fine and updates the database successfully. I run the .sql to import the images and it ran successfully however when I attempt to access the APEX home page, the images are not loaded and the buttons don't do anything. I did some research through google but did not come to anything that resolved my issue. Does anyone have any ideas?
    Thanks for your time...

    If you are using mod_plsql, you need to run @apxldimg.sql script with SYS user file present with Apex installation. Also provide the location of your apex folder as parameter to this script.
    Habib

  • Button Images are not shown

    Dear All,
    In one of our test instance, some button images are not shown, whereas some are.
    They are shown as grey button.
    I searched metalink, according to them patch 1238573 should be installed, which is already installed.
    What could be the reason?
    Also, is there any way to find out which images are missing?
    Regards,
    Ashish Shah

    Hi
    I've seen this happen a few times. The solution is usually to synchronise something called 'the X-Server' with the middle tier. I'm afraid that the technology is over my head, but it does work!
    The X-Server controls how images are rendered in the e-Business Suite. Your DBA should know what this is and it's a simple matter of stopping and restrating the X-server.
    That should do the trick!
    Regards
    Tim

  • Flash objects (images/buttons/etc) does not display on some PC's

    I am trying to deploy an out of the box web application called the Mid-Tier, where some forms/pages in the application have embedded flash images/buttons/icons that do not display on IE despite the fact that there is Flash installed on these PC's. Most of the PC's are XP.
    I suspect it is some of the security settings in IE. Unfortunately security options are disabled to end users so I cannot even get to see what these settings are..
    This web application works perfect on some test PC's that have default browser settings and the same flash version installed.
    The flash objects appear on these screens as white boxes instead of some control buttons and icons that should have been displayed.,. Hence these pages are non functional.
    Any hints?
    Joe

    Hello David,
    except the latest Flash Player you have also and the latest Java installed (Next Generation Java Plug-in 10.25.2 for Mozilla browsers) , check if you activate the plugins : [https://support.mozilla.org/el/kb/troubleshoot-issues-with-plugins-fix-problems#w_determining-if-a-plugin-is-the-problem Determining if a plugin is the problem], select always active.
    see also: [https://support.mozilla.org/en-US/kb/why-do-i-have-click-activate-plugins#os=win7&browser=fx23 Why do I have to click to activate plugins?]
    you said : ''One guy said you could fix it by going Tools > options > content > make sure Automatically load images is checked (but there is no such thing on that tab in my Firefox????)''
    not exist any more from 23.0 version and above (see : http://www.mozilla.org/en-US/firefox/23.0/releasenotes/) because of this : http://limi.net/checkboxes-that-kill , if you 1 (as a value) in '''permissions.default.image''' in [http://kb.mozillazine.org/About:config about:config] you are OK (checked[v]).
    also many site issues can be caused by corrupt cookies or cache. In order to try to fix these problems, the first step is to clear both cookies and the cache.
    Note: ''This will temporarily log you out of all sites you're logged in to.''
    To clear cache and cookies do the following:
    #Go to Firefox > History > Clear recent history or (if no Firefox button is shown) go to Tools > Clear recent history.
    #Under "Time range to clear", select "Everything".
    #Now, click the arrow next to Details to toggle the Details list active.
    #From the details list, check ''Cache'' and ''Cookies'' and uncheck everything else.
    #Now click the ''Clear now'' button.
    Further information can be found in the [[Clear your cache, history and other personal information in Firefox]] article.
    Did this fix your problems? Please report back to us!
    Thank you.

  • Why item button only show #APP_IMAGES# image but not #WORKSPACE_IMAGES#?

    Hi All, I have a item button with Button display attributes - Style as Image. I don't know how come it can only display #APP_IMAGES# image but not #WORKSPACE_IMAGES# image. Please help... Thank you in advance. :)
    Chris

    Hi All, I have a item button with Button display attributes - Style as Image. I don't know how come it can only display #APP_IMAGES# image but not #WORKSPACE_IMAGES# image. Please help... Thank you in advance. :)
    Chris

  • Image button click event not triggered in IE11

    I have an Image button, on its click event textbox is displayed, but it is not working in IE 11. It is working fine on chrome

    Please post questions related to ASP.NET in the ASP.NET forums (http://forums.asp.net).

  • Rollover images with buttons not working on subsequent pages.

    I'm trying to create an interactive PDF wherein images "pop-up" when the cursor rolls over a trigger button. I've successfully employed the Buttons feature to create three such images on one page. However, on a subsequent page images will not appear upon trigger rollover. All three work perfectly on that first page, and I'm using the same procedure on all images/buttons. I checked to see if something was going on in the Tab Order, but each page has its own Tab Order, so I don't know about that. Working in CS6 for Mac.

    In my InDesign file, I have been very meticulous to link each trigger button with the image button and to assign the appropriate actions to the trigger button. Based on what I have learned, when doing this with InDesign, you make both the trigger object--whether an image or, in my case, a box at 0% transparency that covers text--and the object to be shown/hidden into buttons. Maybe that's where I am getting this wrong? Still, that obviously works for some instances and not for others, so this is confounding.
    I do see what you mean about manually adjusting the objects in Acrobat, and that's a trick for adjusting one or two things, but it's tedious to do that with many links in a document that I'm working on. Given the number of "pop-ups" that I want to create for my completed document, the solution has to take place in InDesign.
    Additionally, I have tried just about every permutation of tab orders in the Object-->Interactive-->Set Tab Order feature in InDesign. All to no avail.
    I thank you very much for your time and efforts on this, Gilad. And I apologize for my lack of facility with forum standards (e.g. "How do I post a file, duh?"). Long time reader, first time post-er, haha.

  • "Save image" button of Camera Raw does not save JPEG with modifications made.

    I am using Bridge CC to process my RAW images and make modifications to some JPEG images as well.  I have no need to further alter images in Photoshop at the moment, so I do all modifications in Camera Raw. After altering my images, I then press the "save image" button at the left bottom corner of Camera Raw and choose the settings to save in JPEG.  However, when I upload these JPEG images to a website or when I email them, the image is uploaded without the modifications I had done!  It seems to me that Camera Raw is saving JPEGs the same way it does for RAW images, in a non-destructive manner, only attaching instructions for the images to be displayed properly on Photoshop. But when I save an image in JPEG, I expect the image to be saved entirely with the modifications I made while still keeping the original RAW file.  What goes on then?  What is Camera Raw doing and how do I get to save a modified image in JPEG with Camera Raw?  Would you please explain?
    Many thanks for your help,
    Beza

    Hi,
    What version of camera raw and operating system are you using?

  • Looking for Image Button Applet

    I'm looking for a simple image button applet (normal state, mouse-over and mouse-click) which can refer to a HTML or start a Javascript function. Can anyone help?
    Kippie

    Hi,
    This is the source code. I don't quite understand what I should do with the tokens. I hope this is allright. Thanks for your help
    Kippie.
    import java.net.URL;
    import java.awt.Color;
    import java.util.Vector;
    import java.util.Enumeration;
    import java.util.StringTokenizer;
    import java.applet.Applet;
    import java.applet.AudioClip;
    Program Name:     ImageURLButtonBar
         Author:               Paul Whitelock
         Version:          1.1
         Copyright:          (c) 1997 by Paul Whitelock and Modern Minds, Inc.
         Requires:          ImageURLButtonBar.class
                             ButtonBar.class
                             ButtonBarObserver.class (Interface definition)
                             ButtonRegion.class
                             ButtonAnimate.class
    Modifications: v1.01 (15 April 97)
                             *     Added "sticky" button behavior (controlled
                                  by applet "stick" parameter)
                             v1.03 (25 June 97)
                             *     Added applet parameter "useCodeBase". If useCodeBase
                                  is true, then image file locations will be based on the directory
                                  in which the Java class files are located. If useCodeBase is false, then
                                  the locations will be based on the HTML directory. Note that audio
                                  file locations are always based on the Java directory. The default
                                  for useCodeBase is false (use HTML directory for base).
                             *     The "stick" parameter will now accept a button number in
                                  addition to the value of "true" or "false". If a button number
                                  is specified, then that button will be "stuck" down
                                  when the button bar initializes.
                             *     Added the capability of loading multiple URLs for each button
                                  with an optional target for each URL.
                             v1.1 (25 September 97)
                             *     Added "baseBrighten" and "baseBrightenTint" parameters to control
                                  highlighting for base button bar.
                             *     Added "mouseOverBrighten" and "moBrightenTint" parameters to control
                                  highlighting for base button bar.
                             *     Added "mdBrightenTint" and "mdBrightenAll" parameters to control
                                  highlighting for base button bar. Previous versions of the applet
                                  supported "mouseDownBrighten," but only if button borders were not
                                  drawn for the button-down button bar (the "mdBrightenAll" can be set
                                  to "true" to override the this default behavior).
                             *     An "appletBGColor" parameter has been added to set the
                                  applet background color. The applet background color is
                                  sometimes visible during scrolling or during a page repaint.
         NOTE:               This source code was composed using Microsoft Visual J++
                             with tab stops of 4. Text may not be formatted correctly
                             if another editor is used.
         ******************************** PARAMETERS ********************************
              Applet Parm               ButtonBar Class Parm     Default Value
              ================== =======================     ==================
              appletBGColor
              disableBadURL                                        true
              mouseEnterAudio                                        null (audio disabled)
              mouseClickAudio                                        null (audio disabled)
              buttonDownAudio                                        null (audio disabled)
              stick                                                  false
         *     useCodeBase               base                         false (i.e., use getDocumentBase())
              orient                    barHorizontal               horizontal if applet width > height
              base                    baseBarName                    none - parameter REQUIRED
              mouseOver               mouseOverBarName          null
              mouseOver2               mouseOverBar2Name          null
              mouseDown               mouseDownBarName          null
              mouseDownOver          mouseDownOverBarName     null
              buttonsDisabled          buttonsDisabledBarName     null
              background               backgroundImageName          null
              barXPos                    barXBackgroundPos          0
              barYPos                    barYBackgroundPos          0
              buttonBorders          drawButtonBorders          ButtonBar.BORDERS_NONE
              borderColorTL          borderColorTopLeft          null (Color.white if error)
              borderColorBR          borderColorBottomRight     null (Color.gray if error)
              borderIntensity          borderIntensityPercent     50 (used only if borders)
              borderSize               buttonBorderSize          1 (used only if borders)
              downShift               downShift                    false
              downShiftAmt          downShiftAmt               buttonBorderSize
              baseBrighten          baseBrightenPct
              baseBrightenTint     baseBrightenTint
              mouseOverBrighten     mouseOverBrightenPct
              moBrightenTint          mouseOverBrightenTint
              mouseDownBrighten     mouseDownBrightenPct     
              mdBrightenTint          mouseDownBrightenTint
              mdBrightenAll          mouseDownBrightenAll
              buttonsDisabledDim     buttonsDisabledDimPct     25     (used only if no buttonsDisabled)
              grayBarBrighten          grayBarBrighten               0
              frameRate               frameRate                    150 (used only if mouseOver2)
         *     If useCodeBase is true, then all file locations are based on the Java class file
              directory (i.e., use getCodeBase()).
    public class ImageURLButtonBar extends Applet implements ButtonBarObserver {
         // Instance Variables
         ButtonBar buttonBar;
         Vector buttonURL = new Vector(10, 10);
         Vector buttonURLTarget = new Vector(10, 10);
         Vector buttonDescription = new Vector(10, 10);
         AudioClip mouseEnterAudio = null;
         AudioClip mouseClickAudio = null;
         AudioClip buttonDownAudio = null;
         // Applet Initialization
         public void init() {
              // =================================================================
              // Applet ImageURLButtonBar specific parameters
              // =================================================================
              // appletBGColor
              //          Set applet background color
              String parm = getParameter("appletBGColor");
              if (parm != null) {
                   try {     
                        setBackground(new Color(Integer.parseInt(parm, 16)));
                   catch (Exception e) {
                        reportError("appletBGColor");
              // disableBadURL
              //          If true, then any button with an invalid URL will be disabled
              parm = getParameter("disableBadURL");
              boolean disableBadURL;
              if (parm == null || !parm.equals("false")) disableBadURL = true;
              else disableBadURL = false;
              // mouseEnterAudio
              //          Sound to play each time the mouse enters any of the buttons
              parm = getParameter("mouseEnterAudio");
              if (parm != null) {
                   mouseEnterAudio = getAudioClip(getCodeBase(), parm);
                   if (mouseEnterAudio == null) reportError("Can't load " + parm);
              // mouseClickAudio
              //          Sound to play each time a mouse down click occurs in a button
              parm = getParameter("mouseClickAudio");
              if (parm != null) {
                   mouseClickAudio = getAudioClip(getCodeBase(), parm);
                   if (mouseClickAudio == null) reportError("Can't load " + parm);
              // buttonDownAudio
              //          Sound to play each time a mouse up occurs in a button (i.e, the
              //          button has be toggled through it's "down" position)
              parm = getParameter("buttonDownAudio");
              if (parm != null) {
                   buttonDownAudio = getAudioClip(getCodeBase(), parm);
                   if (buttonDownAudio == null) reportError("Can't load " + parm);
              // stickyBar
              //          If the "stick" applet parameter is "true", then buttons will stay
              //          "stuck" in the down position until another button is clicked.
              //          If the "stick" applet parameter is the number of a button in the
              //          button bar, then that button will be "stuck" down when the
              //          button bar initializes.
              int stickyBar = -1;
              parm = getParameter("stick");
              if (parm != null && !parm.toLowerCase().equals("false")) {
                   try {
                        stickyBar = Integer.parseInt(parm);
                   catch (Exception e) {
                        stickyBar = 0;
              // =================================================================
              // Class ButtonBar specific parameters
              // =================================================================
              // orient (barHorizontal)
              //          If this parameter = 'h' then the button bar is horizontal
              //          If this parameter = 'v' then the button bar is vertical
              //          If this parameter is not specified, then the button bar is
              //          horizontal if the applet width is greater than the applet height
              boolean horizontal;
              parm = getParameter("orient");
              if (parm == null) horizontal = size().width > size().height;
              else horizontal = parm.equals("h") ? true : false;
              // base     (baseBarName)
              //          The base image file for the buttons. This is the only image
              //          file that MUST be specified.
              String baseBar = getParameter("base");
              if (baseBar == null) {
                   reportError("Parameter 'base' REQUIRED!");
                   return;
              // barXPos (barXBackgroundPos)
              // barYPos (barYBackgroundPos)
              //          If a background image is specified then these to parameters
              //          represent the top-left corner location where the button bar
              //          should be placed on the background
              int barXPos = 0, barYPos = 0;
              try {
                   parm = getParameter("barXPos");
                   if (parm != null) barXPos = Integer.parseInt(parm);
                   parm = getParameter("barYPos");
                   if (parm != null) barYPos = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("barXPos or barYPos");
                   barXPos = barYPos = 0;
              // buttonBorders (drawButtonBorders)
              //          "none" = do not draw any button borders
              //          "all"     = draw borders around all button bar buttons
              //          "base"     = draw borders only around buttons on base button bar
              //          "other"     = draw borders around all button bar buttons EXCEPT base button bar buttons
              parm = getParameter("buttonBorders");
              int drawButtonBorders = ButtonBar.BORDERS_NONE;
              if (parm != null) {
                   if (parm.equals("base")) drawButtonBorders = ButtonBar.BORDERS_BASE;
                   else if (parm.equals("other")) drawButtonBorders = ButtonBar.BORDERS_OTHER;
                   else if (parm.equals("all")) drawButtonBorders = ButtonBar.BORDERS_ALL;
              // borderColorTL (borderColorTopLeft)
              // borderColorBR (borderColorBottomRight)
              //          Normally, borders are drawn around buttons by lightening or darkening
              //          the image in the border region. A specific color can be used instead
              //          for the top and left borders and/or the bottom and right borders. The
              //          value specified for either of these two parameters should be a hexadecimal
              //          number (e.g., "FF0000" for red, "888888" for medium gray, etc.).
              Color borderColorTopLeft = null;
              Color borderColorBottomRight = null;
              try {
                   parm = getParameter("borderColorTL");
                   if (parm != null) borderColorTopLeft = new Color(Integer.parseInt(parm, 16));
                   parm = getParameter("borderColorBR");
                   if (parm != null) borderColorBottomRight = new Color(Integer.parseInt(parm, 16));
              catch (Exception e) {
                   reportError("borderColorTL or borderColorBR");
                   borderColorTopLeft = Color.white;
                   borderColorBottomRight = Color.gray;
              // borderIntensity (borderIntensityPercent)
              //          If borders are drawn for buttons, and if a border color is not specified
              //          (see above), then the image in the border region will be lightened or
              //          darkened by this percentage to create the borders.
              int borderIntensityPercent = 50;
              try {
                   parm = getParameter("borderIntensity");
                   if (parm != null) borderIntensityPercent = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("borderIntensity");
                   borderIntensityPercent = 50;
              // borderSize (buttonBorderSize)
              //          The size of borders, if borders are specified.          
              int buttonBorderSize = 1;
              try {
                   parm = getParameter("borderSize");
                   if (parm != null) buttonBorderSize = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("borderSize");
              // downShift
              //          If true, then the button image is shift down and right downShiftAmt
              //          (see below) pixels when the mouse is clicked on the button.
              parm = getParameter("downShift");
              boolean downShift = (parm == null || !parm.equals("true")) ? false : true;
              // downShiftAmt
              //          If downShift is true, then the button image is shift down and right
              //          downShiftAmt (see above) pixels when the mouse is clicked on the button.
              int downShiftAmt = buttonBorderSize;
              try {
                   parm = getParameter("downShiftAmt");
                   if (parm != null) downShiftAmt = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("downShiftAmt");
              // baseBrighten (baseBrightenPct)
              //          The base bar will be lightened by this percentage
              int baseBrightenPct = 0;
              try {
                   parm = getParameter("baseBrighten");
                   if (parm != null) baseBrightenPct = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("baseBrighten");
              // mouseOverBrighten (mouseOverBrightenPct)
              //          A button will be lightened by this percentage when the mouse
              //          moves over a button.
              int mouseOverBrightenPct = 0;
              try {
                   parm = getParameter("mouseOverBrighten");
                   if (parm != null) mouseOverBrightenPct = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("mouseOverBrighten");
              // mdBrightenAll (mouseDownBrightenAll)
              //          A button will be lightened by this percentage when the mouse
              //          moves over a button.
              boolean mouseDownBrightenAll = false;
              parm = getParameter("mdBrightenAll");
              if (parm != null && parm.charAt(0) == 't') mouseDownBrightenAll = true;
              // mouseDownBrighten (mouseDownBrightenPct)
              //          A button will be lightened by this percentage when it is
              //          clicked.
              int mouseDownBrightenPct = 0;
              try {
                   parm = getParameter("mouseDownBrighten");
                   if (parm != null) mouseDownBrightenPct = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("mouseDownBrighten");
              // baseBrightenTint (mouseOverBrightenTint)
              // moBrightenTint (mouseOverBrightenTint)
              // mdBrightenTint (mouseDownBrightenTint)
              Color baseBrightenTint = null;
              Color mouseOverBrightenTint = null;
              Color mouseDownBrightenTint = null;
              try {
                   parm = getParameter("baseBrightenTint");
                   if (parm != null) baseBrightenTint = new Color(Integer.parseInt(parm, 16));
                   parm = getParameter("moBrightenTint");
                   if (parm != null) mouseOverBrightenTint = new Color(Integer.parseInt(parm, 16));
                   parm = getParameter("mdBrightenTint");
                   if (parm != null) mouseDownBrightenTint = new Color(Integer.parseInt(parm, 16));
              catch (Exception e) {
                   reportError("baseBrightenTint, moBrightenTint or mdBrightenTint");
              // buttonsDisabledDim (buttonsDisabledDimPct)
              //          If a button is disabled and if there is no buttonsDisabled image,
              //          then the button will be dimmed by this percentage.
              int buttonsDisabledDimPct = 25;
              try {
                   parm = getParameter("buttonsDisabledDim");
                   if (parm != null) buttonsDisabledDimPct = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("buttonsDisabledDim");
              // grayBarBrighten
              //          If there is no mouseOver image, then the base image will be used for
              //          the mouseOver image, and a grayscale version of the base image will
              //          be used for base button images. This parameter can be used to lighten
              //          COLORS (not grays) in the image before it is converted to grayscale.
              //          This can help if the standard conversion produces buttons that are
              //          too dark.
              int grayBarBrighten = 0;
              try {
                   parm = getParameter("grayBarBrighten");
                   if (parm != null) grayBarBrighten = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("grayBarBrighten");
              // frameRate
              //          If a mouseOver2 image is specified, then this parameter controls
              //          how quickly animation will be performed (using mouseOver and mouseOver2
              //          images) in milliseconds when the mouse is moved over a button.
              int frameRate = 150;
              try {
                   parm = getParameter("frameRate");
                   if (parm != null) frameRate = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("frameRate");
              // =================================================================
              // Instantiate the button bar
              // =================================================================
              try {
                   // Allow the use of documentBase (default) or codeBase for image file
                   // base directory.
                   URL documentBase;
                   parm = getParameter("useCodeBase");
                   if (parm == null || parm.equals("false")) documentBase = getDocumentBase();
                   else documentBase = getCodeBase();
                   // Create the button bar
                   buttonBar = new ButtonBar(
                                                 horizontal,                         /* barHorizontal */
                                                 documentBase,                         /* base */
                                                 baseBar,                              /* baseBarName */
                                                 getParameter("mouseOver"),     /* mouseOverBarName */
                                                 getParameter("mouseOver2"),     /* mouseOverBar2Name */
                                                 getParameter("mouseDown"),     /* mouseDownBarName */
                                                 getParameter("mouseDownOver"), /* mouseDownOverBarName */
                                                 getParameter("buttonsDisabled"),/* buttonsDisabledBarName */
                                                 getParameter("background"),     /* backgroundImageName */
                                                 barXPos,                              /* barXBackgroundPos */
                                                 barYPos,                              /* barYBackgroundPos */
                                                 drawButtonBorders,               /* drawButtonBorders */
                                                 borderColorTopLeft,               /* borderColorTopLeft */
                                                 borderColorBottomRight,          /* borderColorBottomRight */
                                                 borderIntensityPercent,          /* borderIntensityPercent */
                                                 buttonBorderSize,                    /* buttonBorderSize */
                                                 downShift,                         /* downShift */
                                                 downShiftAmt,                         /* downShiftAmt */
                                                 baseBrightenPct,                    /* baseBrightenPct */
                                                 baseBrightenTint,                    /* baseBrightenTint */
                                                 mouseOverBrightenPct,               /* mouseOverBrightenPct */
                                                 mouseOverBrightenTint,          /* mouseOverBrightenTint */
                                                 mouseDownBrightenAll,               /* mouseDownBrightenAll */
                                                 mouseDownBrightenPct,               /* mouseDownBrightenPct */
                                                 mouseDownBrightenTint,          /* mouseDownBrightenTint */
                                                 buttonsDisabledDimPct,          /* buttonsDisabledDimPct */
                                                 grayBarBrighten,                    /* grayBarBrighten */
                                                 frameRate                              /* frameRate */     
                   // =================================================================
                   // Add buttons to the button bar
                   // =================================================================
                   ButtonRegion buttonToAdd;
                   String buttonNbr, urlString;
                   URL urlForButton;
                   int nbr = 0;
                   int buttonStart, buttonSize;
                   // Initialize button on bar flag (used to determine if at least one button
                   // was successfully added to the button bar)
                   boolean buttonOnBar = false;
                   // This loop will be exited when no more buttons can be found in the HTML
                   while (true) {
                        // Construct the prefix for the button parameters
                        buttonNbr = "button" + ++nbr;
                        // Find the starting offset and the size of the button
                        // If null is returned as the starting offset parameter value for the
                        // button, then all buttons should have been read so the loop can
                        // be exited.
                        try {
                             parm = getParameter(buttonNbr + "Start");
                             if (parm == null) break;
                             buttonStart = Integer.parseInt(parm);
                             buttonSize = Integer.parseInt(getParameter(buttonNbr + "Size"));
                        catch (Exception e) {
                             reportError("Button" + nbr + " start or size in error or missing");
                             buttonStart = 0;
                             buttonSize = 0;
                        // Create a ButtonRegion for the button
                        // The button ID will be set to the number of the button (this will
                        // be converted to an integer later when a buttonBarEvent is received).
                        buttonToAdd = new ButtonRegion("" + nbr, buttonStart, buttonSize);
                        // If the buttons on this button bar are "sticky" buttons, then
                        // enable "sticky" behavior for this button. The button will always
                        // "pop-up" whenever another button is clicked.
                        if (stickyBar >= 0) {
                             buttonToAdd.stickyButton(true, ButtonRegion.POPUP_ALWAYS, false);
                             // If the current button number matches the value of stickyBar, then the
                             // current button should be "stuck" down for its initial state.
                             if (stickyBar == nbr) buttonToAdd.setStuck(true);
                        // Try to add the button (i.e., the ButtonRegion) to the buttonBar
                        if (buttonBar.addButton(buttonToAdd)) {
                             // Set flag to indicate that at least one button has been added
                             buttonOnBar = true;
                             // The button was successfully added, so save the button's description
                             // (which will be displayed in the status bar) and the target frame
                             // for the button URL in the appropriate Vector.
                             buttonDescription.addElement(getParameter(buttonNbr + "Desc"));
                             buttonURLTarget.addElement(getParameter(buttonNbr + "Target"));
                             // Try to create a URL for the button.
                             // If the URL is invalid, then place an error message in the
                             // buttonURLTarget Vector (this will be used to warn the user
                             // when the button is clicked). Also, if disableBadURL is true, then
                             // disable the button.
                             String theURL;
                             urlString = getParameter(buttonNbr + "URL");
                             if (urlString != null) {
                                  Enumeration urls = new StringTokenizer(urlString);
                                  while (urls.hasMoreElements()) {
                                       theURL = (String)urls.nextElement();
                                       try {
                                            urlForButton = new URL(theURL);
                                       catch (Exception e) {
                                            try {
                                                 urlForButton = new URL(getDocumentBase(), theURL);
                                            catch (Exception e2) {
                                                 reportError("Button" + nbr + " has invalid URL");
                                                 buttonURLTarget.setElementAt("Invalid URL", nbr - 1);
                                                 urlString = null;
                                                 break;
                             else {
                                  reportError("Button" + nbr + " has no URL");
                                  buttonURLTarget.setElementAt("No URL", nbr - 1);
                             buttonURL.addElement(urlString);
                   // Remove any unused elements in the Vectors
                   buttonURL.trimToSize();
                   buttonURLTarget.trimToSize();
                   buttonDescription.trimToSize();
                   // If no buttons were added, throw exception
                   if (!buttonOnBar) throw new IllegalArgumentException("No buttons on bar");
                   // Let the buttonBar know that all buttons have been defined. This is
                   // really only necessary if downShift is true, but it won't hurt calling
                   // the method in either case.
                   buttonBar.allButtonsDefined();
                   // Add the applet as an observer so that the applet will be notified
                   // when button events occur.
                   buttonBar.addButtonObserver(this);
                   // Enable the button bar now that all buttons have been defined.
                   // (the buttonBar is disabled when it is created and must be
                   // specifically enabled).
                   buttonBar.enable(true);
                   // Add the buttonBar to the applet
                   setLayout(null);
                   add(buttonBar);
              catch (Exception e) {
                   reportError("Can't create ButtonBar\n" + e);
         // buttonBarEvent
         //          This method is called by the ButtonBar whenever a button event occurs
         //          It provides the ButtonBar that the event occurred for, the button ID
         //          that the event occurred for, and the event type.
         public void buttonBarEvent(ButtonBar barID, String buttonID, int buttonEvent) {
              String description;
              // The buttonBar will send an IMAGES_READY event when all button bar images
              // have been prepared. We are not interested in this event, but only in
              // certain "action" events that occur for a button.
              if (buttonEvent != ButtonBar.IMAGES_READY) {
                   // A number in String format was assigned as the buttonID when each
                   // ButtonRegion was created. The buttonID String will now be converted
                   // back into a number that can be used as a Vector index to retrieve
                   // button specific information (i.e., URL, target frame, and description).
                   int buttonNbr = Integer.parseInt(buttonID) - 1;
                   switch (buttonEvent) {
                        // If a mouseDown event has occurred for the button, and if an
                        // AudioClip is available for this event, play the AudioClip.
                        case ButtonBar.MOUSE_CLICK:     
                             if (mouseClickAudio != null) mouseClickAudio.play();
                             break;
                        // If the mouse has been moved over a button, display the button's
                        // description in the browser's status area. If the button that the mouse
                        // is over is an active button, and if there is an AudioClip available
                        // for this event, then play the audio clip.
                        case ButtonBar.MOUSE_ENTER:     
                        case ButtonBar.MOUSE_ENTER_DISABLED:
                             description = (String)buttonDescription.elementAt(buttonNbr);
                             if (description != null) showStatus(description);
                             if (mouseEnterAudio != null && buttonEvent == ButtonBar.MOUSE_ENTER) {
                                  mouseEnterAudio.play();
                             break;
                        // If the mouse has been moved off of a button and if the button has
                        // description text associated with it, then clear the browser's
                        // browser's status area.
                        case ButtonBar.MOUSE_EXIT:
                        case ButtonBar.MOUSE_EXIT_DISABLED:
                             description = (String)buttonDescription.elementAt(buttonNbr);
                             if (description != null) showStatus("");
                             break;
                        // If the button has been depressed (i.e., a mouseDown followed by
                        // a mouseUp for the same button) then load the URL(s) for the button
                        // in the target frame(s), if specified. If the URL is null, then the
                        // URL was found to be missing or invalid, so display the text stored in
                        // the buttonURLTarget Vector in the brower's status area. If there is
                        // an AudioClip for the event, play the audio.
                        case ButtonBar.BUTTON_DOWN:
                             // Get the string of URLs and Targets for the button
                             String urlString = (String)buttonURL.elementAt(buttonNbr);
                             String targetString = (String)buttonURLTarget.elementAt(buttonNbr);
                             // If there is at least one URL for the button
                             if (urlString != null) {
                                  URL urlForButton;
                                  String theURL;
                                  String theTarget;
                                  Enumeration urls = new StringTokenizer(urlString);
                                  Enumeration targets = null;
                                  if (targetString != null) targets = new StringTokenizer(targetString);
                                  // While there is another URL for the button
                                  while (urls.hasMoreElements()) {
                                       // Get the next String token that represents a URL
                                       theURL = (String)urls.nextElement();
                                       // Convert the String to a URL
                                       try {
                                            urlForButton = new URL(theURL);
                                       catch (Exception e) {
                                            try {
                                                 urlForButton = new URL(getDocumentBase(), theURL);
                                            catch (Exception e2) {
                                                 urlForButton = null;
                                                 break;
                                       // If the String was successfully convert to a URL
                                       if (urlForButton != null) {
                                            // If there is a target for this URL
                                            if (targets != null && targets.hasMoreElements()) {
                                                 // Get the String that represents the target
                                                 theTarget = (String)targets.nextElement();
                                                 // If the target String does NOT begin with a "-",
                                                 // then load the URL in the target
                                                 if (theTarget.charAt(0) != '-') {
                                                      getAppletContext().showDocument(urlForButton, theTarget);
                                                 // Else a target for this URL should not be used
                                                 else {
                                                      getAppletContext().showDocument(urlForButton);
                                            // Else there is no target for this URL, so just show
                                            // the URL.
                                            else {
                                                 getAppletContext().showDocument(urlForButton);
                             // Else URL is missing or invalid
                             else showStatus((String)buttonURLTarget.elementAt(buttonNbr));
                             if (buttonDownAudio != null) buttonDownAudio.play();
                             break;
         // Error reporting
         private void reportError(String message) {
              message = "[ImageURLButtonBar] Error - " + message;
              System.out.println(message);
              showStatus(message);
    }

  • RE: [iPlanet-JATO] image button handling

    Hi Todd,
    from what I have seen so far on the Project they are just buttons on
    the page.
    In the interim, I modified RequestHandlingViewBase.acceptsRequest() to
    handle the matching of parameter and command child names.
    from
    if (request.getParameter(commands)!=null)
    return getCommandChildNames()[i];
    to
    if (request.getParameter(commands[i])!=null ||
    (request.getParameter(commands[i]+ ".x")!=null ))
    return getCommandChildNames()[i];
    This fixed the problem with the image buttons in our cases.
    Kostas
    -----Original Message-----
    From: Todd Fast
    Sent: 10/27/00 6:21 AM
    Subject: Re: [iPlanet-JATO] image button handling
    Hi Kostas--
    I wanted to get some feedback on the known issue of the
    handleXXXXRequest method not being fired for buttons which have
    images, due to the the browser submitting
    the pixel coordinates back to the server like this:
    Page1.ImageButton1.x=...
    Page1.ImageButton1.y=...
    As the ND conversion project we are currently working on heavily uses
    image buttons we would like to get and indication if and when a patch
    is planned for this.
    Our current work around is to remove the src attribute from the JATO
    tags in the JSPs.We are currently working on getting this fixed. One question--what is
    the
    relative type of usage of image buttons in your project? Are they just
    buttons on the page (view bean), or do they appear in tiled views as
    well?
    Todd
    [email protected]
    [Non-text portions of this message have been removed]

    OK, here's what I'm trying to do: We have, like you said, a menu
    page. The pages that it goes to and the number of links are all
    variable and read from the database. In NetD we were able to create
    URLs in the form
    pgXYZ?SPIDERSESSION=abcd
    so this is what I'm trying to replicate here. So the URL that works
    is
    pgContactUs?GXHC_GX_jst=fc7b7e61662d6164&GXHC_gx_session_id_=cc9c6dfa5
    601afa7
    which I interpreted to be the equivalent of the old Netd way. Our
    javascript also loads other frames of the page in the same manner.
    And I believe the URL-rewritten frame sources of a frameset look like
    this too.
    This all worked except for the timeout problem. In theory we could
    rewrite all URLs to go to a handler, but that would be...
    inconvenient.

  • Image content not defined in TileList

    I have two images on a canvas, one is directly on the canvas using inline code, the other is embedded in a tilelist. Both images render. When I click and drag the inline image, the drag proxy appears normally. When I click and drag the image in the tile list, I get an error when I try to make a copy of the bitmap. This is occurring because the content of the image in the tile list is NULL, even though the source value is correct and the image has been loaded. I'm assuming this is some sort of itemRenderer issue, but I'm not clear on how it retains the source of the image, but not the content. If it's duplicating the image and referencing another bitmap, how do I access that bitmap?
    The code is below with the exception of the image.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.managers.DragManager;
            import mx.core.DragSource;
            [Bindable] private var images:ArrayCollection=new ArrayCollection;
                private function init():void{
                    i.source="images/1.png"; //set image source that is placed directly on canvas, this image has a drag proxy
                    var i2:Image=new Image; //create new image to be added into tile list, this image does not have a valid drag proxy because content is missing
                    i2.source="images/1.png";
                    images.addItem(i2);
                private function mouseMoveHandlerTileList(event:MouseEvent):void
                    var tl:TileList=TileList(event.currentTarget);
                    var image:Image=tl.selectedItem as Image;
                    if (image){
                        //Here the image contains the correct source, but no content.
                        initiateDrag(event, image);
                private function mouseMoveHandlerImage(event:MouseEvent):void
                    var image:Image=Image(event.currentTarget);
                    if (image){
                        //Here the image does contain content
                        initiateDrag(event, image);
                private function initiateDrag(event:MouseEvent, image:Image):void{
                        var dragInitiator:Image=image;
                        var ds:DragSource = new DragSource();
                        ds.addData(image, "item");
                        var dragProxy:Image = new Image;
                        var data:BitmapData=Bitmap(image.content).bitmapData.clone(); //image.content is not null for imageon canvas, but is null for image in tile list
                        dragProxy.source=new Bitmap(data);
                        DragManager.doDrag(dragInitiator, ds, event, dragProxy);
        ]]>
    </mx:Script>   
        <mx:Canvas id="c" width="100%" height="100%">
            <mx:Image id="i" mouseMove="mouseMoveHandlerImage(event)" x="400" y="400"/>
            <mx:TileList id="t" dataProvider="{images}" mouseMove="mouseMoveHandlerTileList(event)"
                x="0" y="0"
                >
                <mx:itemRenderer>
                    <mx:Component>
                        <mx:Image source="{data.source}"/>
                    </mx:Component>
                </mx:itemRenderer>
                </mx:TileList>
        </mx:Canvas>
    </mx:Application>

    If this post answered your question or helped, please mark it as such.
    Accessing items in containers when renders are used can be problematic, because Flex recycles the items for large data sets.
    So this code works fine but uses a Repeater. You may have to do some thinking to rework your concept, but this works:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Script>
        <![CDATA[
          import mx.collections.ArrayCollection;
          import mx.managers.DragManager;
          import mx.core.DragSource;
          [Bindable] private var images:ArrayCollection=new ArrayCollection([
            "assets/images/BobSmith.jpg"
          private function mouseMoveHandlerTileList(event:MouseEvent):void {           
            var image:Image=Image(event.currentTarget);
            if (image){
              initiateDrag(event, image);
          private function mouseMoveHandlerImage(event:MouseEvent):void {           
            var image:Image=Image(event.currentTarget);
            if (image){
              initiateDrag(event, image);
          private function initiateDrag(event:MouseEvent, image:Image):void{
            var dragInitiator:Image=image;
            var ds:DragSource = new DragSource();
            ds.addData(image, "item");
            var dragProxy:Image = new Image;
            var data:BitmapData=Bitmap(image.content).bitmapData.clone(); //image.content is not null for imageon canvas, but is null for image in tile list
            dragProxy.source=new Bitmap(data);
            DragManager.doDrag(dragInitiator, ds, event, dragProxy);
        ]]>
      </mx:Script>   
      <mx:HBox>
        <mx:Canvas id="canvas" width="400" height="600" borderColor="0x000000" borderStyle="solid" borderThickness="3">
          <mx:Repeater id="rp" dataProvider="{images}">
            <mx:Image id="img" source="{rp.currentItem}" mouseMove="mouseMoveHandlerTileList(event)"/>         
          </mx:Repeater>
        </mx:Canvas>
        <mx:Image id="i" mouseMove="mouseMoveHandlerImage(event)" source="assets/images/BobSmith.jpg"/>
      </mx:HBox>
    </mx:Application>

  • Image does not appear in applet.

    I am reading the book, Teach Yourself Java in 21 Days.
    There is an example in Ch.11 that shows how to load an image into the applet.
    I have tried to use the code provided as is along with an image as defined in the code. I have also uploaded the html, class and image to a folder on the web. Unfortunately, the image does not appear in the applet. The image does have an image that I created using ms paint.
    Here is the code I am currently using from the book:
    import java.awt.Graphics;
    import java.awt.Image;
    public class LadyBug2 extends java.applet.Applet {
         Image bugimg;
         public void init() {
             bugimg = getImage(getCodeBase(),
                 "ladybug.gif");
         public void paint(Graphics g) {
             int iwidth = bugimg.getWidth(this);
             int iheight = bugimg.getHeight(this);
             int xpos = 10;
             // 25 %
            g.drawImage(bugimg, xpos, 10,
                iwidth / 4, iheight / 4, this);
             // 50 %
             xpos += (iwidth / 4) + 10;
             g.drawImage(bugimg, xpos , 10,
                  iwidth / 2, iheight / 2, this);
             // 100%
             xpos += (iwidth / 2) + 10;
             g.drawImage(bugimg, xpos, 10, this);
             // 150% x, 25% y
             g.drawImage(bugimg, 10, iheight + 30,
                 (int)(iwidth * 1.5), iheight / 4, this);
    }I tried placing the image in an images folder and I also tried changing the code to getImage(getDocumentBase(), "ladybug.gif")
    as well as tried getImage(getCodeBase(), "ladybug.gif") in order to try and grab the image from the same directory as the class file and the html file.
    The image file's name is: ladybug.gif
    The code in the html file:
    <HTML>
    <HEAD>
    <TITLE>Lady Bug</TITLE>
    </HEAD>
    <BODY>
    <P>
    <APPLET CODE="LadyBug2.class" WIDTH=1024 HEIGHT=500>
    </APPLET>
    </BODY>
    </HTML>
    I have gotten previous applet examples from the book to work. One of them did have an error in the author's code which I fortunately was able to overcome. This time, I am afraid, the error eludes me.
    Thanks in advance.
    I do see that there is no start/stop/run in this version, but I believe this should still work because of the init. I am guessing that maybe the problem lies somewhere in there.
    Message was edited by:
    gnikollaj

    According to the javadoc:
    getImage
    public Image getImage(URL url,
    String name)Returns an Image object that can then be painted on the screen. The url argument must specify an absolute URL. The name argument is a specifier that is relative to the url argument.
    This method always returns immediately, whether or not the image exists. When this applet attempts to draw the image on the screen, the data will be loaded. The graphics primitives that draw the image will incrementally paint on the screen.
    Parameters:
    url - an absolute URL giving the base location of the image.
    name - the location of the image, relative to the url argument.
    Returns:
    the image at the specified URL.
    I am confused as to how to use the name after the url.
    Should it read something like:
    bugimg = getImage("http://g.jtrusty.com/JavaApplet/", "LadyBug.gif");
    EDIT: I still get the same error, cannot find symbol at getImage.
    Message was edited by:
    gnikollaj

Maybe you are looking for