Images in my game applet

I am having problems changing an image for buttons in my game applet. I can give them initial images but when i cant figure out how to change them.
The method that houses the statement is static - but i cant use static method when i am getting images using getClass(). PLEASE HELP!
P.S. My applet is housed in a jar!
d6 = new ImageIcon(getClass().getResource("images/dom"+ active.playerDominoes[0].x + active.playerDominoes[0].y + ".gif"));
domino6.setIcon(d6);
//ERROR.............
non-static method getClass() cannot be referenced from a static context
        d6 = new ImageIcon(getClass().getResource("images/dom"+ active.playerDominoes[0].x + active.playerDominoes[0].y + ".gif"));

another easier way is:
exchange getClass() with
any class, like ImageIcon.class(The thing is that static classes "has no this" but the method
getClass() returns the class of the this-object.)
/n

Similar Messages

  • Create Image from Stream in Applet via Servlet

    First of all, I apologize if this isn't posted to the proper forum, as I am dealing with several topics here. I think this is more of an Image and I/O problem than Applet/Servlet problem, so I thought this forum would be most appropriate. It's funny...I've been developing Java for over 4 years and this is my first post to the forums! :D
    The problem is I need to retrieve a map image (JPEG, GIF, etc) from an Open GIS Consortium (OGC) Web Map Server (WMS) and display that image in an OpenMap Applet as a layer. Due to the security constraints on Applets (e.g., can't connect to a server other than that from which it originated), I obviously just can't have the Applet create an ImageIcon from a URL. The OpenMap applet will need to connect to many remote WMS compliant servers.
    The first solution I devised is for the applet to pass the String URL to a servlet as a parameter, the servlet will then instantiate the URL and also create the ImageIcon. Then, I pass the ImageIcon back to the Applet as a serialized object. That works fine...no problems there.
    The second solution that I wanted to try was to come up with a more generic and reusable approach, in which I could pass a URL to a servlet, and simply return a stream, and allow the applet to process that stream as it needs, assuming it would know what it was getting from that URL. This would be more usable than the specific approach of only allowing ImageIcon retrieval. I suppose this is actually more of a proxy. The problem is that the first few "lines" of the image are fine (the first array of buffered bytes, it seems) but the rest is garbled and pixelated, and I don't know why. Moreover, the corruption of the image differs every time I query the server.
    Here are the relevant code snippets:
    =====================Servlet====================
        /* Get the URL String from the request parameters; This is a WMS
         * HTTP request such as follows:
         * http://www.geographynetwork.com/servlet/com.esri.wms.Esrimap?
         *      VERSION=1.1.0&REQUEST=GetMap&SRS=EPSG:4326&
         *      BBOX=-111.11361,3.5885315,-48.345818,71.141304&
         *      HEIGHT=480&...more params...
         * It returns an image (JPEG, JPG, GIF, etc.)
        String urlString =
            URLDecoder.decode(request.getParameter("wmsServer"),
                              "UTF-8");
        URL url = new URL(urlString);
        log("Request parameter: wmsServer = " + urlString);
        //Open and instantiate the streams
        InputStream urlInputStream = url.openStream();
        BufferedInputStream bis = new
            BufferedInputStream(urlInputStream);
        BufferedOutputStream bos = new
            BufferedOutputStream(response.getOutputStream());
        //Read the bytes from the in-stream, and immediately write them
        //out to the out-stream
        int read = 0;
        byte[] buffer = new byte[1024];
        while((read = bis.read(buffer, 0, buffer.length)) != -1) {
            bos.write(buffer, 0, buffer.length);
        //Flush and close
        bos.flush();
        urlInputStream.close();
        bis.close();
        bos.close();
        .=====================Applet=====================
        //Connect to the Servlet
        URLConnection conn = url.openConnection();
        conn.setUseCaches(false);
        conn.setRequestProperty("header", "value");
        conn.setDoOutput(true);
        //Write the encoded WMS HTTP request
        BufferedWriter out =
            new BufferedWriter( new OutputStreamWriter(
                conn.getOutputStream() ) );
        out.write("wmsServer=" + URLEncoder.encode(urlString, "UTF-8"));
        out.flush();
        out.close();
        //Setup the streams to process the servlet response
        BufferedInputStream bis = new
            BufferedInputStream(conn.getInputStream());
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        //Read the bytes and immediately write to the out-stream
        int read = 0;
        byte[] buffer = new byte[1024];
        while((read = bis.read(buffer, 0, buffer.length)) != -1) {
            bos.write(buffer, 0, buffer.length);
        //Flush and close
        bis.close();</code>
        bos.flush();</code>
        byte[] imageBytes = bos.toByteArray();
        //Create the Image/ImageIcon
        Toolkit tk = Toolkit.getDefaultToolkit();
        Image image = tk.createImage(imageBytes);
        imageIcon = new ImageIcon(image);
        Could this be an offset problem in my buffers? Is there some sort of encoding/decoding I am missing somewhere?
    Thanks!
    Ben

    Without having a probing look, I was wondering why you do the following...
    while((read = bis.read(buffer, 0, buffer.length)) != -1) {
    bos.write(buffer, 0, buffer.length);
    while((read = bis.read(buffer, 0, buffer.length)) != -1) {
    bos.write(buffer, 0, buffer.length);
    }Your int 'read' holds the number of bytes read in but you then specify buffer.length in your write methods?!? why not use read? otherwise you will be writing the end of the buffer to your stream which contains random memory addresses. I think thats right anyway...
    Rob.

  • 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

  • How can I upload a (image) file through an applet ?

    How can I upload a (image) file through an applet ?

    have a look at http://www.haller-systemservice.net/jupload/
    i'm using Apache Jakarta HTTPClient to create a new HTTP connection to the webserver and sending a new POST request, which holds the image file. (So it's RFC1867 conform)
    there is also an open source implementation of such an applet on sourceforge. it's also called JUpload, but i think it's not maintained any more.

  • Having problem with importing images to a java applet in web broswer

    I'm creating a mini 2d game just for fun and I am running it as a applet with the JApplet class.
    This is my html file.
    <html>
    <body>
    <applet code=ambiDexApplet.class name=ambiDexApplett archive=ambiDexApplet.jar
         width=640 height=480>
         <param name="Player" value="Player.class">
         <param name="Actor" value="Actor.class">
         <param name="Tail_Bead" value="Tail_Bead.class">
         <param name="Block" value="Block.class">
         <param name="Morphable" value="Morphable.class">
         <param name="Item" value="Item.class">
         <param name="GameObject" value="GameObject.class">
         <param name="leftImg" value="Player_Left3.gif">
         <param name="rightImg" value="Player_Right3.gif">
         <param name="img1" value="bgImgFinal.jpg">
         <param name="img2" value="Block_Tower2.gif">
    </applet>
    </body>
    </html>However every time i try to run the program i get the following error when i open the java console.
    java.security.AccessControlException: access denied (java.io.FilePermission Images\Player_Left3.gif read)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    Obviously, the applet is not letting me read the image files. By the way, the .class files and the image files are all in same directory. So can anyone help me please?

    Unfortunately, yes--I've tried it that way over and over, and every other way I could think of.  The files are all in one folder, and I've converted the raw files to both tiffs and jpegs.  I even tried converting them to jpegs at the final pixel dimensions.  Each folder that I have used only contains one type of file, and they are all part of the same sequence and sequentially numbered.  I have even tried renumbering the files with numbers first, numbers last, numbers only, moving underscores.  I moved the files from my external hard-drive to the desktop ... I have a lot less hair than I had only a few days ago!
    I've looked at a few other tutorials that outline the same sequence of steps, and tried them over and over, and then changing one step at a time to make sure that it was not a single step that caused the problem.
    The thing that is really bugging me is that it works fine if I use the different approach of using the place command instead. 
    Anyway, thanks for all of your time.  It's going to be a lot simpler to just stick with 'place' command and I will likely do that, but I tend take things like this as a challenge.  I like to know WHY it won't work for me.  Sometimes it seems that there is just no logical explanation!
    Stuart

  • Question - making rummy card game applet

    Hi, I am not sure if this is the right place to be putting this, if not please let me know. I'm trying to make an applet for the card game rummy for my final project for school. I was wondering if I could get some help on how to load a card image from a file and randomizing the images for the deal button or if not that then I am also trying a much simpler way due to time constraints. I was trying to make two arrays of strings: one for the facevalue of the card and another for the suit value, then randomize those and draw a string to the correct places for the dealt hand. I can't seem to get this to work well so far. Any help is greatly appreciated. Here is the code for the basic gui that I have now.
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.util.Random;
    import java.lang.*;
    public class CardGame extends Applet implements ActionListener {
         Button Deal;
         Button NewGame;
         Button PutDown;
         Color bgColor;
         Color rectColor;
         Image deck;
         MediaTracker mt;
         CheckboxGroup radioGroup;
         Checkbox radio1;
         Checkbox radio2;
         Checkbox radio3;
         Checkbox radio4;
         Checkbox radio5;
         Checkbox radio6;
         Checkbox radio7;
    **Its hard to tell but the arrays are commented out for now.     
         //String[] faceValue = {"ACE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING"};
    //     String[] suitValue = {"CLUBS", "HEARTS", "SPADES", "DIAMONDS"};
         public void init()
              setLayout(null);
              mt = new MediaTracker(this);
              Deal = new Button("Deal");
              NewGame = new Button("New Game");
              PutDown = new Button("Put Down");
              Deal.setBounds(750, 450, 75, 25);
              NewGame.setBounds(750, 475, 75, 25);
              PutDown.setBounds(750, 425, 75, 25);
              add(Deal);
              add(NewGame);
              add(PutDown);
              Deal.addActionListener(this);
              NewGame.addActionListener(this);
              PutDown.addActionListener(this);
              radioGroup = new CheckboxGroup();
              radio1 = new Checkbox(" ", radioGroup, false);
              radio2 = new Checkbox(" ", radioGroup, false);
              radio3 = new Checkbox(" ", radioGroup, false);
              radio4 = new Checkbox(" ", radioGroup, false);
              radio5 = new Checkbox(" ", radioGroup, false);
              radio6 = new Checkbox(" ", radioGroup, false);
              radio7 = new Checkbox(" ", radioGroup, false);
              add(radio1);
              add(radio2);
              add(radio3);
              add(radio4);
              add(radio5);
              add(radio6);
              add(radio7);
              radio1.setBounds(143, 525, 10, 10);
              radio2.setBounds(222, 525, 10, 10);
              radio3.setBounds(301, 525, 10, 10);
              radio4.setBounds(380, 525, 10, 10);
              radio5.setBounds(459, 525, 10, 10);
              radio6.setBounds(538, 525, 10, 10);
              radio7.setBounds(617, 525, 10, 10);
         public void Randomize()
              //this is where I need the help mostly.
         public void Stop()
         public void actionPerformed(ActionEvent evt)
         if (evt.getSource()== Deal)
                   setBackground(Color.green); //test
              else
                   Deal.setLabel("Not there, here!"); //another test
         if(radio1.getState())
                   setBackground(Color.blue); //just a test to make sure I know how to use the radio buttons
         public void paint(Graphics g) {
              g.drawString("Welcome to Rummy!!", 300, 50 );
              g.drawRect(100, 100, 600, 440);
              g.drawRect(110, 420, 75, 100);
              g.drawRect(190, 420, 75, 100);
              g.drawRect(270, 420, 75, 100);
              g.drawRect(350, 420, 75, 100);
              g.drawRect(430, 420, 75, 100);
              g.drawRect(510, 420, 75, 100);
              g.drawRect(590, 420, 75, 100);
              g.drawRect(110, 120, 75, 100);
              g.drawRect(190, 120, 75, 100);
              g.drawRect(270, 120, 75, 100);
              g.drawRect(350, 120, 75, 100);
              g.drawRect(430, 120, 75, 100);
              g.drawRect(510, 120, 75, 100);
              g.drawRect(590, 120, 75, 100);
              g.drawRect(300, 250, 75, 100);
              g.drawRect(380, 250, 75, 100);
              g.drawString("A S", 220, 445);
    }

    thanks for that...could I use something like this for the playing card class though:
    public class Card {
    public final static int SPADES = 0, // Codes for the 4 suits.
    HEARTS = 1,
    DIAMONDS = 2,
    CLUBS = 3;
    public final static int ACE = 1, // Codes for the non-numeric cards.
    JACK = 11, // Cards 2 through 10 have their
    QUEEN = 12, // numerical values for their codes.
    KING = 13;
    private final int suit; // The suit of this card, one of the constants
    // SPADES, HEARTS, DIAMONDS, CLUBS.
    private final int value; // The value of this card, from 1 to 11.
    public Card(int theValue, int theSuit) {
    // Construct a card with the specified value and suit.
    // Value must be between 1 and 13. Suit must be between
    // 0 and 3. If the parameters are outside these ranges,
    // the constructed card object will be invalid.
    value = theValue;
    suit = theSuit;
    public int getSuit() {
    // Return the int that codes for this card's suit.
    return suit;
    public int getValue() {
    // Return the int that codes for this card's value.
    return value;
    public String getSuitAsString() {
    // Return a String representing the card's suit.
    // (If the card's suit is invalid, "??" is returned.)
    switch ( suit ) {
    case SPADES: return "Spades";
    case HEARTS: return "Hearts";
    case DIAMONDS: return "Diamonds";
    case CLUBS: return "Clubs";
    default: return "??";
    public String getValueAsString() {
    // Return a String representing the card's value.
    // If the card's value is invalid, "??" is returned.
    switch ( value ) {
    case 1: return "Ace";
    case 2: return "2";
    case 3: return "3";
    case 4: return "4";
    case 5: return "5";
    case 6: return "6";
    case 7: return "7";
    case 8: return "8";
    case 9: return "9";
    case 10: return "10";
    case 11: return "Jack";
    case 12: return "Queen";
    case 13: return "King";
    default: return "??";
    public String toString() {
    // Return a String representation of this card, such as
    // "10 of Hearts" or "Queen of Spades".
    return getValueAsString() + " of " + getSuitAsString();
    } // end class Card
    except now how would I make something like this random I know theres a bunch of work before that, but just curious. Thanks

  • Problem with Image I/O and applet

    I am having trouble using Image I/O to load a PNG image in an applet. I am just using a very basic applet that simply loads the image from a URL and that's it, and the exception I get is -
    java.lang.SecurityException: Unable to create temporary file
    at java.io.File.checkAndCreate(File.java:1294)
    at java.io.File.createTempFile(File.java:1385)
    The simple applet is as follows -
    import java.awt.image.*;
    import java.net.*;
    import java.io.*;
    import javax.swing.*;
    import javax.imageio.ImageIO;
    public class CheckImageApplet extends JApplet
    public BufferedImage bi = null;
    public void init()
    URL url = null;
    BufferedImage bi = null;
    try
    url = new URL( "http://localhost/CheckImageSystem/checkimages/backGS.png" );
    catch ( MalformedURLException mfue )
    try
    bi = ImageIO.read( url );
    catch ( IOException ioe )
    Any thoughts on this exception would be appreciated

    It seems the line
    bi = ImageIO.read( url );
    fails. Can't see anything else. Perhaps this method needs to create a temp image for some reason, and tries to do this at the local harddrive (not allowed). Use getImage(URL, String); instead. ImageIO isn't intended for applets, I think, so you should use the applet methods.
    Nille

  • Unable to download images in a swing applet (1.3.1) behind proxy

    Hi
    One of my client have a proxy server and firewall and when they try to access my webserver
    then all the AWT applet are downloaded and rendered on client properly. However, the swing applet written
    using JDK 1.3.1 is downloaded and rendered but it doesn't display anything properly as images
    are not down loaded. I have used media tracker to add images to it like oMediaTracker.addImage( oImage, index );
    and then oMediaTracker.waitForAll();
    Java console display at client looks as follows:
    Java(TM) Plug-in: Version 1.3.1
    Using JRE version 1.3.1 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\toy
    Proxy Configuration: no proxy
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    q: hide console
    s: dump system properties
    t: dump thread list
    x: clear classloader cache
    0-5: set trace level to <n>
    Applet Initialization start...
    Applet Image Initialization start...
    Trace level set to 5: basic, net, security, ext, liveconnect ... completed.
    Opening      http:MyServer/24/x.gif
    Connecting     http:MyServer/24/x.gif with no proxy
    Connecting
    http:MyServer/24/x.gif with cookie "ASPSESSIONIDGQGQQVWC=DLNBDAOABFANEPJFFIGOOIPG;
    JSESSIONID=25Ais2tF1eBkevUhAa2akocfShzNdzyL7yC1I7UhJl7Z6BLZrnQK!
    -1149265879"
    Opening      http:MyServer/40/y.gif
    Connecting      http:MyServer/40/y.gif with no proxy
    Connecting      http:MyServer/40/y.gif with cookie "ASPSESSIONIDGQGQQVWC=DLNBDAOABFANEPJFFIGOOIPG;
    JSESSIONID=25Ais2tF1eBkevUhAa2akocfShzNdzyL7yC1I7UhJl7Z6BLZrnQK!
    -1149265879"
    Opening     http://MyServer/sun/beans/infos/PanelBeanInfo.class
    Connecting     http://MyServer/sun/beans/infos/PanelBeanInfo.class with no proxy
    Connecting http://MyServer/sun/beans/infos/PanelBeanInfo.class with cookie "ASPSESSIONIDGQGQQVWC=DLNBDAOABFANEPJFFIGOOIPG;
    JSESSIONID=25Ais2tF1eBkevUhAa2akocfShzNdzyL7yC1I7UhJl7Z6BLZrnQK!
    -1149265879"
    Opening http://MyServer/java/awt/ContainerBeanInfo.class
    Connecting http://MyServer/java/awt/ContainerBeanInfo.class with no proxy
    Connecting http://MyServer/java/awt/ContainerBeanInfo.class
    Client machine tries to access these images but i never receive a call at web server end when i see
    IIS log.
    CLient environment:
    -Windows 2000/XP/NT
    -Internet explorer 6.0 SP1 or IE 5.5 SP2
    with connection->LAN Setting->Use Automatic configuration script(only checked)
    -Java Plugin configured like proxies->Use Browser Setting
    -JDK 1.3.1 plug in at client(downloaded and Installed automatically on demand)
    -Object tag used to download applet and plugin
    -Firewall and proxy(i don't know about vendor)
    My webserver environment
    Windows 2000/iis 5.0 with anonymous authentication and
    cache-control header set to no-store (so that proxy doesn't cache anything)
    QUESTIONS:
    ~~~~~~~~~
    Q.1. When i try from home network that has a proxy then everything works fine. At client site everything except
    image download works fine. I mean jars are downloaded and i can see anything drawn using JAVA API.
    When i try from home i see following java console trace
    Java(TM) Plug-in: Version 1.3.1
    Using JRE version 1.3.1 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\wuko
    Proxy Configuration: Automatic Proxy Configuration
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    q: hide console
    s: dump system properties
    t: dump thread list
    x: clear classloader cache
    0-5: set trace level to <n>
    Trace level set to 5: basic, net, security, ext, liveconnect ... completed.
    Applet Initialization start...
    Applet Image Initialization start...
    Opening http://MyServer/24/connec.gif
    Connecting http://MyServer/24/connec.gif with proxy=197.168.1.100:808
    Connecting http://MyServer/24/connec.gif with cookie "ASPSESSIONIDQQGQQCYU=GBJFAOABCJFPDMGFHEKLDACA; JSESSIONID=26yu5m1b4upVuXoAoDmtMbWXQmetQpyzqjFANszo9vFubujT4qGX!-1149265879"
    Opening http://MyServer/24/cool.gif
    Connecting http://MyServer/24/cool.gif with proxy=197.168.1.100:808
    Connecting http://MyServer/24/cool.gif with cookie "ASPSESSIONIDQQGQQCYU=GBJFAOABCJFPDMGFHEKLDACA; JSESSIONID=26yu5m1b4upVuXoAoDmtMbWXQmetQpyzqjFANszo9vFubujT4qGX!-1149265879"
    etc
    I can't set the plugin at client to use automatic script just like IE browser uses. This option is not supported in JRE1.3.1. Looks to be supported in JRE1.4.1. My client doesn't want to set manual proxy ip and port in plugin as they don't want to reveal this info to everyone within the company for security reason.
    Q.2. Why some classes like PanelBeanInfo.class, JAppletBeanInfo.class are downloaded
    from my server while it doesn't exist at my webserver. Any thing stupid IE or plugin doing
    at client. Any Idea?
    Thanks in advance for any help.
    Ratan

    Thanks to Mike and other friends who already replied on this topic.
    Here is my research analysis:
    Answer to Question 1:
    ~~~~~~~~~~~~~~~~~~~~~
    The solution is to bundle all the images with JAR. Bundle with jar whichever needs it. However, it might require duplicacy.
    Image img = null;
    try
    img = Toolkit.getDefaultToolkit().getImage(getClass().getResource(fileName));
    catch (Exception e) { }
    In this case make sure that you have image at the same location where you access it. For example if you have to access an image in package class com.awt.ui.MyClass then your image should also be at location ..\com\awt\ui
    Note: It will require image duplicacy in your JAR but it solves the problem. It gives the advantage of fewer download from server.
    Answer to Question 2:
    ~~~~~~~~~~~~~~~~~~~~~
    IE treats applet as an active-X and try to look for these classes in your JAR. SUN has stopped its support in JDK1.3.1 and plus. What one can do is to create dummy classes with these names and bundle it with your JAR. You have to create these dummy classes if you enable Basic authentication on your web server then browser will try to look for these classes on the server and continue to prompt you for login and password. It might bother your customer un-necessarily to enter login and password too many times prompted by plug-in (plug in).
    --Ratan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Using disk images for learning games?

    Hello, I've 2 g3 imacs running 9.2.2, and they are for the grandkids to use learning games on.
    The kids are very hard on the software disks. When I found out about disk images I made them up, now to install them properly. The games are installed, but where to store the disk images? The desk top icons for the games will work after the disk images have been double clicked and the mounted disk image appears on the desktop, but when the imacs are turned off the mounted disk image is lost. How or where does one put the disk images in a safe place so the kids don't get at them, and the disks are mounted every time, without actually starting, when the Mac is started? Start up menu?
    I'm planning on multiple accounts with them having a standard account with game privileges so they don't mess the whole thing up. If their accounts get too messed up for me to repair I figured on maybe deleting the account and opening up a new one? Any Ideas are very welcome.
    Thank you,
    EZ

    Hi, EZ -
    You're quite welcome.
    I had a thought with regard to the disk image files. Are they in a .smi format, or are they in a .img format?
    The .img format requires the assistance of the Disk Copy utility in order to mount the image. This is the standard format generated by the user version of Disk Copy. It requires that Disk Copy be available to Finder to act as a helper app in order to mount the image.
    The .smi format does not - .smi stands for Self-Mounting Image. The user version of Disk Copy can not make this format; but I have seen a utility to convert .img format to .smi format. The slight advantage with this format is that Disk Copy does not need to be available to Finder.
    In both cases the default is to run a checksum verification before the image is finally mounted. The delay caused by this verification can be inconvenient - verification is intended to confirm the integrity of the image after it has been copied, transported, or downloaded, but is usually not necessary when the image resides on a hard drive.
    The checksum verification for .img file types can be removed. With the image not mounted, open Disk Copy. In Disk Copy's Preferences (Edit menu), uncheck the Verify Checksum item. Save the Preferences window. Then select Convert Image from the Image menu, navigate to the disk imge file from which you want to remove the verifiaction, select it and click the Open button. A new window will appear, similar to a Save As type window. Leave everything in that window untouched (unless you want to change the base name of the file - the extension .img should be left intact) and click the Save button. The image will be mounted, the original disk image file will be deleted, and a new disk image file created. Unfortunately creating the new image file takes quite a while since it is creating a new one, not actually modifying the old one - but it does get rid of the intrusion of the checksum verification requirement.
    I verified on my G4/500 running OS 9.1 that a .img file (one I had made from a game CD years ago) dropped into the Startup Items folder will be mounted automatically at the end of the startup sequence. I also tested with an alias to the .img file, and it, too, worked fine - the disk image was mounted automatically at the conclusion of the startup sequence.
    When you make the alias to the disk image file (the .img one), be sure you are placing it into the Startup Items folder, and not the Startup Items (disabled) folder.
    If you have the machine set to use Simple Finder (which removes Finder's keyboard commands and many menu options for Finder), that may interfere with items in the Startup Items folder being run at startup. Or, it may not - I have not checked that.
    *** Edit ***
    I have verified that the alias to a .img file will mount the disk image even when the machine is booted using Simple Finder.
    Another thought, related to Multiple Users - if you do decide to set up Multiple Users, and the disk images are of type .img, be sure to authorize Disk Copy for each of the accounts for which the disk images are to be mounted. If you have the disk image files in a .smi format, since Finder views that file type as being an application, you would need to authorize each of those disk image files for each account which is to have access to them.

  • Saving canvas as an image: embedded in an applet

    hi everyone,
    I'm trying to save shapes I've drawn in a canvas as a jpg. This works, thanks to a solution I found somewhere in one of these forums. However, I need to embed the application in an applet, and in that case it doesn't work anyone. Here is some code that works when I don't use applets:
    public class MenuItemHandler implements ActionListener{
              public void actionPerformed(ActionEvent e) {
                   try{
                        FileDialog fd = new FileDialog(new Frame(), "Save as JPG", FileDialog.SAVE);
              fd.setFile("canvas.jpg");
              fd.setVisible(true);
              String name = fd.getDirectory() + fd.getFile();
              File file = new File(name);
                        ImageUtils utils = new ImageUtils();
                        BufferedImage image = utils.createComponentImage(tc);
                        utils.encodeImage(image,file);
                   catch(Exception ex) {
                        ex.printStackTrace(); }
         class ImageUtils {
              private JPEGImageEncoder encoder = null;
              private FileOutputStream fileStream = null;
              public BufferedImage createComponentImage(Component component){
                   BufferedImage image = (BufferedImage)component.createImage(component.getWidth(),component.getHeight());
                   Graphics graphics = image.getGraphics();
                   if(graphics != null) { component.paintAll(graphics); }
                   return image;
              public void encodeImage(BufferedImage image, File file) throws IOException{
                   fileStream = new FileOutputStream(file);
                   JPEGEncodeParam encodeParam = JPEGCodec.getDefaultJPEGEncodeParam(image);
                   encoder = JPEGCodec.createJPEGEncoder(fileStream);
                   encoder.encode(image,encodeParam);
                   fileStream.close();
    When the code is embedded in an applet, I see my appliaction and I get my save dialog box, but there won't be written any file anymore. I suppose it has something to do with the fact that I don't use getDocumentBase() or getCodeBase(), but I'm not sure about that, and if this is the reason, I don't know exactly how to implement it in the code.
    I hope that someone can help me!!
    Thanks in advance!

    hi everyone,
    I'm trying to save shapes I've drawn in a canvas as a jpg. This works, thanks to a solution I found somewhere in one of these forums. However, I need to embed the application in an applet, and in that case it doesn't work anyone. Here is some code that works when I don't use applets:
    public class MenuItemHandler implements ActionListener{
              public void actionPerformed(ActionEvent e) {
                   try{
                        FileDialog fd = new FileDialog(new Frame(), "Save as JPG", FileDialog.SAVE);
              fd.setFile("canvas.jpg");
              fd.setVisible(true);
              String name = fd.getDirectory() + fd.getFile();
              File file = new File(name);
                        ImageUtils utils = new ImageUtils();
                        BufferedImage image = utils.createComponentImage(tc);
                        utils.encodeImage(image,file);
                   catch(Exception ex) {
                        ex.printStackTrace(); }
         class ImageUtils {
              private JPEGImageEncoder encoder = null;
              private FileOutputStream fileStream = null;
              public BufferedImage createComponentImage(Component component){
                   BufferedImage image = (BufferedImage)component.createImage(component.getWidth(),component.getHeight());
                   Graphics graphics = image.getGraphics();
                   if(graphics != null) { component.paintAll(graphics); }
                   return image;
              public void encodeImage(BufferedImage image, File file) throws IOException{
                   fileStream = new FileOutputStream(file);
                   JPEGEncodeParam encodeParam = JPEGCodec.getDefaultJPEGEncodeParam(image);
                   encoder = JPEGCodec.createJPEGEncoder(fileStream);
                   encoder.encode(image,encodeParam);
                   fileStream.close();
    When the code is embedded in an applet, I see my appliaction and I get my save dialog box, but there won't be written any file anymore. I suppose it has something to do with the fact that I don't use getDocumentBase() or getCodeBase(), but I'm not sure about that, and if this is the reason, I don't know exactly how to implement it in the code.
    I hope that someone can help me!!
    Thanks in advance!

  • Adding image to JDialog in Applet

    Well.. I've decided to make my Applet load via a JDialog. Which I know is possible :). And to a start I'll make a very simple Applet in the JDialog, including a background picture, which I just can't add! So to make a long story short, I want an image in my JDialog, but my code gives me a nullPointerException during the Runtime.. Here's the exact Runtime error:
    Exception in thread "main" java.lang.NullPointerException
            at applet.<init>(applet.java:16)
            at applet.main(applet.java:100)And here's my exact applet.java file:
    import java.applet.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.swing.plaf.metal.*;
    public class applet extends Applet implements Runnable
        private ImagePanel panel;   
    public applet()
         panel.createGUI();
        public void init()
        public void run()
    public void start()
         Thread thread = new Thread(this);
         thread.start();
    public void stop()
    public void destroy()
    public void paint(Graphics g)
    private class ImagePanel extends JPanel
        BufferedImage buffered = null;
        public ImagePanel(String name)
            try
                buffered = ImageIO.read(new File(name));
                setPreferredSize(new Dimension(buffered.getWidth(), buffered.getHeight()));
            } catch(IOException ioe)
                ioe.printStackTrace();
        public void paintComponent(Graphics g)
            if (buffered == null)
                g.drawString("No Image", 10, 40);
            else
                g.drawImage(buffered, 0, 0, null);
        public void createGUI()
         MetalLookAndFeel.setCurrentTheme(new BlackTheme());
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            JPopupMenu.setDefaultLightWeightPopupEnabled(false);
         JDialog dialog = new JDialog();
      dialog.setTitle("Applet loading via. JDialog");
      Container container = dialog.getContentPane();
      ImagePanel panel = new ImagePanel("background.gif");
      dialog.pack();
      dialog.setSize(1000, 1000);
      dialog.setVisible(true);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        public static void main(String[] args)
         applet app = new applet();
    }And I don't see any errors, but still.. Runtime error.. -.-' So a little bit of help would really be appretaiced!

    Okay I guess I spoke to soon.. :O Now I have no Runtime error but my JDialog is completly empty.. And my BlackTheme stopped working.. Not It's a blue theme instead..
    Here take a look at my applet.java:
    import java.applet.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.swing.plaf.metal.*;
    public class applet extends Applet implements Runnable
        ImagePanel panel = new ImagePanel("background.gif");  
    public applet()
         panel.createGUI();
        public void init()
        public void run()
    public void start()
         Thread thread = new Thread(this);
         thread.start();
    public void stop()
    public void destroy()
    public void paint(Graphics g)
    private class ImagePanel extends JPanel
        BufferedImage buffered = null;
        public ImagePanel(String s)
            try
                buffered = ImageIO.read(new File(s));
                setPreferredSize(new Dimension(buffered.getWidth(), buffered.getHeight()));
            } catch(IOException ioe)
                ioe.printStackTrace();
        public void paintComponent(Graphics g)
            if(buffered == null)
                System.out.println("No image to display.");
            else
                g.drawImage(buffered, 0, 0, null);
        public void createGUI()
            MetalLookAndFeel.setCurrentTheme(new BlackTheme());
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            JPopupMenu.setDefaultLightWeightPopupEnabled(false);
         JDialog dialog = new JDialog();
      dialog.setTitle("Applet loading via. JDialog");
      Container container = dialog.getContentPane();
      ImagePanel panel = new ImagePanel("background.gif");
      dialog.pack();
      dialog.setSize(1000, 1000);
      dialog.setVisible(true);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        public static void main(String[] args)
         applet app = new applet();
    }

  • Show an image created in an applet

    Hello all,
    I do an applet that creates me an image in a BufferedImage. The problem I has, is that I wanto to show the image in a new webBrowser and I don't want to certificate the applet so I don't want save the image to my disk an then shows What I would have to do? Upload it to the web server? How can I do this?

    I Too Suffering from the same problem. If any One Have the solution to the problem then please help me

  • Png images not shown in applet when opened in internet explorer

    hi all,
    I am using some transparent PNG images in my applet . Its working properly in appletviewer as well as netscape but images just disappear in internet explorer.
    same image appears in internet explorer but not in applet in internet explorer.
    can anybody help me ?
    thanks

    The java version that IE has doesn't have support for PNG, only gif and jpeg.

  • Why is the  image not scrolling in applet ?

    Hello,
    I am using drawImage to draw the image on screen and everytime i am increasing the X values but still the image just remains there only. It doesn't scroll. How can i solve this?
    import java.applet.Applet;
    import java.awt.*;
    public class ImageScroller extends Applet implements Runnable{
         Image image;
         Thread t;
         int height,width;
         int x;
         public void init(){
              image = getImage(getCodeBase(),"3.jpg");
              x = 50;
              t = new Thread(this);
              t.start();
         public void run(){
              Graphics g = getGraphics();
              while(true){
                   try{
                        x+=50;
                        g.clearRect(0,0,800,600);
                        g.drawImage(image,x,x,this);
                        if(x>width)
                             x=0;
                        Thread.sleep(10);
                   catch(InterruptedException ex){}
    }

    I think what you want is something like this:
    import java.applet.Applet;
    import java.awt.*;
    public class ImageScroller extends Applet implements Runnable{
         Image image;
         Thread t;
         int height,width; // These arent used anywhere...
         int x;
         public void init(){
              image = getImage(getCodeBase(),"3.jpg");
              x = 50;
              t = new Thread(this);
              t.start();
         public void run(){
              while(true){
                   repaint();
                   try {
                        Thread.sleep(10);
                   catch(InterruptedException ex) {}     
         public void paint(Graphics g)
              x+=50;
              g.clearRect(0,0,800,600);
              g.drawImage(image,x,x,this);
              if(x>width)
                   x=0;
    }

  • Cant access image, in jar, from applet

    I have seen this question posted in various places but have not had any luck solvin my problem. Im using the Java Plugin 1.3
    Here is my html :
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    width="700" height="200" align="baseline"
    codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
    <PARAM NAME="code" VALUE="com.hlboyd.ImageSequenceTimer">
    <PARAM NAME="archive" VALUE="ImageSequenceTimerImages.jar,ImageSequenceTimer.jar">
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
    No Java 2 SDK, Standard Edition v 1.3 support for APPLET!!
    </OBJECT>
    My applet class is stored in one of the jars.
    It is found and runs fine, until it trys to load an image that is found in the other jar.
    The images are at the top level in their jar.
    The image name is T1.gif.
    InputStream in=getClass().getResourceAsStream("T1.gif");
    URL url=getClass().getResource("T1.gif");
    Both these methods return null.
    Can anyone suggest why these methods are returning null?
    Many thanks
    Heather

    I consolidated the jars - so that now the images and
    java class files are in the same jar.
    The getResouce() method still returns null.
    I am really stuck - I simply cant get the applet to
    see the images.
    How are you attempting to get the images? If you're using Class.getResource(), then as was mentioned above, make sure the class file that has the Class.getResource() code in it, is in the same jar as the images. Then make sure you're referencing the images correctly.
    For example:
    Given that in the class:
    mypackage.ImageLoader
    you have the code:
    ImageLoader.class.getResource(someVal);
    If you want to load an image from the same jar called logo.gif in the same package (i.e. shows up as /mypackage/logo.gif), then someVal should be "logo.gif".
    If the image is in a different directory/package then someVal should look like "/somepackage/logo.gif".
    Basically, the relative path (someVal) starts from the package that the code (and class) is in. If the image is in a different package, you must start the someVal with a "/" and go from there.
    I got the same thing to work this way.

Maybe you are looking for