Simple slideshow help

Hi, I want to create a simple slideshow but my app fails with a NPE when it attempts to read in the first image.
import javax.swing.JFrame;
import javax.swing.JFileChooser;
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.util.Vector;
import java.awt.Graphics;
public class Main extends JPanel implements Runnable
    private static Vector imagesArray;
    private static volatile Image currentImage;
    private static volatile boolean isInterrupted=false;
    private String strCurrentDir=System.getProperty("user.dir");
    //gets the current working directory
    private JFrame frame;
    private JPanel panel;
    public static void main(String[] args)
        new Main();
    public Main()
        frame = new JFrame();
        panel = new JPanel();
        frame.getContentPane().add(panel);
        getImages();    //prompt the user to select images
        Thread animationThread = new Thread(this);
        animationThread.start();
    public void getImages()
        String strTextFieldContents="";
        //open file chooser so the user can find the file
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setCurrentDirectory(new File(strCurrentDir));
        //sets file choose to use the current working directory
        fileChooser.addChoosableFileFilter((new ImagesFilter()));
        fileChooser.setDialogTitle("Please select image files");
        int returnVal = fileChooser.showOpenDialog(new JFrame());
        if (returnVal == JFileChooser.APPROVE_OPTION)
                File temp=fileChooser.getSelectedFile();
                strTextFieldContents=temp.getAbsolutePath();
                imagesArray.add((String)strTextFieldContents);
        else{}
        imagesArray.trimToSize();
    public void run()
        while(isInterrupted==false)
            for(int i=0; i<imagesArray.size(); i++)
                try
                    Thread.sleep(200);   //display the image for 200ms at a time
                catch(InterruptedException e)
                    System.out.println("Interrupted");
                // If the Toolkit cannot find the file or load the data it
                // gives no warning. You must check on the loading status
                // for yourself.
                MediaTracker mt = new MediaTracker(this);
                mt.addImage(currentImage, 0);
                try
                    mt.waitForID(0);
                catch(InterruptedException e)
                    System.out.println("media tracker interrupted");
                        int status = mt.statusAll(false);
                if((status & MediaTracker.COMPLETE) != MediaTracker.COMPLETE)
                    System.out.println("status = " + status);
                // getImage is asynchronous, ie, it doesn't wait for the
                // image data to load. So you may need to stop to load it.
                Toolkit toolkit = Toolkit.getDefaultToolkit();
                String strImageLoc=(String)imagesArray.elementAt(i);
                //currentImage = toolkit.getImage("Cuboid_Obstacle.jpg");
                currentImage = toolkit.getImage(strImageLoc);
                currentImage=(BufferedImage)imagesArray.elementAt(i);
                panel.repaint();
    public void paintComponent(Graphics g)
        //super.paintComponent(g);
        Toolkit.getDefaultToolkit().sync();
        if (currentImage!=null)
            g.drawImage (currentImage, 0, 0, this);
}

The compiler tells you which line of your code generates the NullPointerException. Analyze that line to determine which of your references may be null.
Hint: Declaring a variable reference does not initialize it!
Then deal with the ClassCastException the same way.
db

Similar Messages

  • A simple slideshow program for 68k OS7 Macs suggestions pls

    I'm looking for a simple slideshow program for my old 68k OS7 Macs. I just want to have some PICTs display on a set time period or key press. Nothing fancy.
    I can get Claris to this but wonder if HyperCard can. I'm no expert on HC but it seems to be designed for this exact job. Do I need to find a "stack" or some already made item to open in HC then attach my piks? Any suggestions?

    It would be possible to use HyperCard, although you may need to do a little programming if you go with it. If you use a blank HyperCard stack, you can assign one picture per card and link them. Clickable buttons would be the easiest way to do this. Which version of HyperCard are you using?
    An old version of PowerPoint would work fine too. Anything older than PowerPoint 98 runs on a 68K unless you are using a 68000 processor, in which case you'll need one of the pre-1994 versions.
    Believe it or not, Kid Pix is a possible answer to this as well. Any version from Kid Pix 2 onward (as well as the Kid Pix Companion addon for the original Broderbund version) contains an application called Slide Show, which is used with files in the PICT format. You can display an image for up to 30 seconds and add transitions between slides.

  • Can Touch be used to create a simple slideshow of images?

    Can Touch be used to create a simple slideshow of images?

    No, sorry, but you can, of course, produce a series of images for use in a slideshow.

  • Creating a Simple Slideshow w music as a movie for a web page.

    Hi all,
    I would like to create a simple slideshow with music saved as a mp4 movie for a web page. I'd like to use basic transitions like crossfades between the pictures and other fun stuff
    A few questions:
    1 - Would I be better of  creating this in iPhoto or iMovie or Keynote?
    2 - Any hints in getting started?
    note: I guess I'll post this on iPhoto area also...

    You are probably better off in iMovie. You will have a lot more control. With iPhoto, as far as I know, all slides would have to be the same length, and you would need to pick music from iPhoto. With iMovie, you can customize slide length, make them change on the beat, use your own music, etc.
    I would use Keynote only if you want to include text and bullets where the photo is only part of the slide.

  • Simple Slideshow isn't working in IE 7 and 8

    I am using the simple slideshow widget for the first time. When I add the widget to Dreamweaver it seems to work fine. When I go to browser lab and review the results for Internet Explorer 7 and 8 all I see is the list view of the photos that I have included to the slideshow menu. Things seem to be fine for IE9, Chrome, Firefox and Opera. It seems as though IE isn't seeing the javascript. Does anyone have any ideas?
    thanks in advance.
    the sight is www.hairlinecreations.us

    thanks for responding.
    It turns out I had to place the 3 java calls for the spry navigation bar before the java calls for the slideshow. There must be something in conflict that interferes with the slideshow.
    thanks again
    idealneal

  • Hi when i send imessages it keeps showing up as my email address on the receiving device. I know its something simple! Help please.

    Hi when i send imessages it keeps showing up as my email address on the receiving device. I know its something simple! Help please.

    Hi Megamanfx,
    If you are having issues with the Sent From settings in iMessage on your iPhone, you may find the following article helpful:
    iOS 6 and OS X Mountain Lion: Link your phone number and Apple ID for use with FaceTime and iMessage
    http://support.apple.com/kb/HT5538
    Regards,
    - Brenden

  • Need help with simple slideshow

    Hi everyone,
    I'm a complete newbie at Flash and trying to build my first
    movie, just a basic slideshow. I have about a dozen jpegs all same
    size, and I just want a basic fade out and fade in the next one, no
    user interractivity necessary. I imported the jpegs into the
    FlashMX (v6) environment, converted to graphic symbols, created a
    movie clip symbol for each image, and set up the fade in/fade out.
    Each individual movie clip works OK, but I can't figure out how to
    arrange my movie clips to display in succession in the main
    timeline. I can set frame 1 as a keyframe and place a movie clip in
    that frame, test the movie, and the clip plays. I put a keyframe in
    frame 2 and put the next movie clip in that frame, then nothing
    works. Any suggestions? If someone could just explain the basic
    principal of playing several movie clips in succession, or just
    point me in the right diresction, I would be very grateful.
    Thanks much,
    Dave

    Here is some of the action script for the slideshow.
    This first bit sets up the automatic interval transitions in
    the main movie timeline
    function nextImage()
    mc_slide.mc_transition.play();
    } // End of the function
    function waitImage()
    clearInterval(slideTimer);
    var slideTimer = setInterval(nextImage, timer * 1000);
    nextImage();
    } // End of the function
    function pauseSlide()
    mc_slide.mc_quicktransition.gotoAndPlay(2);
    } // End of the function
    var timer = 8;
    var pauseTime = 20;
    var slideTimer = setInterval(nextImage, timer * 2000);
    stop ();
    the movieclip loaders that load each movie clip are embedded
    with the transition animation.
    this is the code in the embedded mc-it loads the 1st movie
    clip and allows the user to manually jump to any of the other movie
    clips.
    emptyMC.loadMovie("frame1.swf");
    var pageAddress = "about:blank";
    btn1.onRelease = function ()
    _parent.pauseSlide();
    gotoAndStop(1);
    btn2.onRelease = function ()
    _parent.pauseSlide();
    gotoAndStop(2);
    btn3.onRelease = function ()
    _parent.pauseSlide();
    gotoAndStop(3);
    btn4.onRelease = function ()
    _parent.pauseSlide();
    gotoAndStop(4);
    stop();
    I need to know how to put the code for the automation of the
    slideshow pause until each movieclip has finished loading and also
    at the same time disable the manual control of the movie clips
    before they are fully loaded.

  • JQuery - Linking images in a simple slideshow

    Hey guys, I am working on creating a very simply image slider that links  to different pages of my site. It is all but complete! however, when I  wrap my image in "A Href" tags they screw up the transition (Or fade)  effect codded into my slideshow. Here is the code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"/>
    <title>Simple jQuery Slideshow from JonRaasch.com</title>
    <script type="text/javascript" src="jquery-1.2.6.min.js"></script>
    <script type="text/javascript">
        Simple jQuery Slideshow Script
        Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify
    function slideSwitch() {
        var $active = $('#slideshow IMG.active');
        if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
        // use this to pull the images in the order they appear in the markup
        var $next =  $active.next().length ? $active.next()
            : $('#slideshow IMG:first');
        // uncomment the 3 lines below to pull the images in random order
        // var $sibs  = $active.siblings();
        // var rndNum = Math.floor(Math.random() * $sibs.length );
        // var $next  = $( $sibs[ rndNum ] );
        $active.addClass('last-active');
        $next.css({opacity: 0.0})
            .addClass('active')
            .animate({opacity: 1.0}, 1000, function() {
                $active.removeClass('active last-active');
    $(function() {
        setInterval( "slideSwitch()", 5000 );
    </script>
    <style type="text/css">
    /*** set the width and height to match your images **/
    #slideshow {
        position:relative;
        height:350px;
        width : 610px;
    #slideshow IMG {
        position:absolute;
        top:0;
        left:0;
        z-index:8;
        // opacity:0.0;
    #slideshow IMG.active {
        z-index:10;
        opacity:1.0;
    #slideshow IMG.last-active {
        z-index:9;
    </style>
    </head>
    <!-- this will work with any number of images -->
    <!-- set the active class on whichever image you want to show up as the default
    (otherwise this will be the last image) -->
    <div id="slideshow">
        <img src="images\missions-slide.jpg" alt="Slideshow Image 1" />
        <img src="images\young-lions-slide.jpg" alt="Slideshow Image 2" />
        <img src="images\welcome-to-icc-slide.jpg" alt="Slideshow Image 3" />
    </div>
    </body>
    </html>
    The three images on the botem are to be linked to different pages, and I  read on the developers forum (The developer of this code that is) that I  need to reference the images as Div's. I just don't know how. Also, I am using DWCS5.
    I am fluent in C++, java, C# and old school html, so I understand some  of this code, but i don't know the basics enough to be able to know what  to do here. Please help! Thanks!

    You can look at the javax.swing.ImageIcon class and add that to your JOptionPane...
    - MaxxDmg...
    - ' How should I know, I just wrote the thing... '

  • Just a simple slideshow

    www.melinanicolaide.com
    this is a website i'm redoing
    need to do the same,
    but only a bit refined on the edges.
    The menu stays almost the same
    and we want to slideshow as simple as that.
    I know it's a simple task
    but my knowledge is rusty
    any sites to help me out?
    thanks/

    >> any sites to help me out?
    Google
    Dave -
    www.offroadfire.com
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • Simple viewer help needed please

    I need help with this exact problem please which was posted by Kirby on 9th Feb
    I can't save into the idisk/web folder although I can copy the files over after they refuse to open (if that means anything)...
    "This is for Old Toad. I checked out your demo site which is awesome. I read the tutorial,
    Examples of SimpleViewer and Flash Album Exporter Slideshows (plugins for iPhoto)
    ADDED USING HTML SNIPPET AND IFRAME
    This was great but I am still running into a roadblock. The issue seems to be that in the URL that is given on your demo page...
    http://web.me.com/youraccountname/slideshow folder/index.html
    ....it says to enter my account name (which I did).
    I am uploading the simple-viewer folder to my iDisk using the Go menu but inside of the Web/Sites folder there is no folder called Slideshow Folder. So am I right in thinking that the URL has nothing to point too because that folder isn't there? Why isn't it there? And is there anything I can do to solve this? Is there another place the simple-viewer folder should be on my idisk?"

    Hi:
    When you create the simpleviewer slideshow with iPhoto's plugin there should be a folder created on your HD that contains the items seen in the screenshot below:
    The folder was named simpleviewer because that's what I named it during the export from iPhoto. That's the same folder as I refer to as "Slideshow folder". It can be whatever you name it when exporting from iPhoto. Upload that folder to your iDisk/Web/Sites folder as shown below:
    In the iFrame code use the following URL to the index.html file inside the simpleviewer folder:
    http://web.me.com/YourMMe_AccountName/simplerviewer/index.html
    That should do it.

  • Simple button help needed!

    I want to make a simple round button that glows when you
    mouse over it and depresses when you click it.
    Apparently to do this I need to use Filters to make the glow
    and bevels. But Filtersonly work on movie clips, buttons and text.
    So I make a circle and convert it into a button symbol
    (Btn1). Then I make another button symbol (Btn2) and use the first
    button symbol (Btn 1) on the Up Over and Down frames of Btn 2.
    Assorted Filters are applied to Btn 1 on the Up Over and Down
    frames to get the effects I want.
    I test the button (Btn2) using Enable Simple Buttons. It
    works perfectly - glows on mouse over and depresses on click. Then
    I try Test Movie -- and the button doesn't work!!!
    Not does it work when exported as a SWF file!!!
    I watched a tutorial video that came with my Flash Pro 8
    Hands-On-Training (HOT) book and he used pretty much the same
    technique -- except he only tested his button with Enable Simple
    Buttons. I'll bet my house his didn't work with Test Movie either!
    The stupid thing, is I was just able to achieve exactly what
    I wanted very quickly using LiveMotion 2!
    What is wrong here? Why is it so impossible to create a glow
    button in Flash? Why has it been easy in Live Motion for years?
    All help appreciated!
    Thanks
    craig

    I thought the nesting button situation might be the problem
    BUT there is no other way to apply Filters to Up, Down, etc. Also,
    a freaking tutorial book described that as a valid method, but
    obviously it ain't.
    I tried using movieclips as well but basically had the same
    problem.
    I mentioned LiveMotion 2 because that ancient program can do
    easily what Flash Pro 8 seems incapable of.
    What is the logic behind not allowing Filters to be applied
    to simple graphics? It's absurd!
    There's got to be a way...

  • Simple Button Help

    Hi
    I am new to flash and having a bit of trouble. All I would
    like to do is be able to create a button and have that button
    navigate to a frame.
    What I am doing now is:
    Insert - New Symbol - Button and name the button (ex: about)
    Go through the up/over/down/hit steps and return to scene 1
    I then drag the about button onto the stage
    I give the about button the instance name of about_btn
    In the action layer, I enter the following code:
    stop();
    _root.about_btn.onRelease = function(){
    gotoAndStop("about");
    "about" being the keyframe I would like to go to
    When I test the button, I get error 1120: "Access of
    undefined property onrelease".
    I am working on adobe flash cs3 on a pc. I know this is a
    very simple issue and any help would be greatly appreciated.
    Thank you.

    what have you done so far? what don't you know how to do?
    where are you stuck at? need way more detail to help any
    further.

  • Error while rendering menus/slideshows--HELP!!

    Ok. I've done my homework on this forum and the Mac help pages and nothing fixes this problem.
    Initial issue: I have an iDVD project with pictures in drop zones, audio in the background, two menu pages each with 3-4 movies (both .dv and .mpg4), and a menu page with nothing but background audio and text.
    While trying to create a disk image I received the (familiar to this board) error that there was an "Error while rendering menus/slideshows" and that burning was to be aborted.
    What I tried:
    I cleared 41 gigs of free space on my boot drive.
    I transfered all of my media files onto the boot drive.
    I verified and repaired permissions. (until I did these last two items, the program wouldn't just fail, it would crash my computer, giving me the multilanguage *you must restart* greyed out page).
    I downloaded the most recent quicktime, iTunes, and Mac OS updates.
    I created a new iDVD project with only one video file (sepearately tried just a .dv and .mpg4 file).
    I removed all quicktime extensions from my 'library/quicktime' and '~library/quicktime' folders.
    I changed from 'higher quality' to 'better performance'.
    I told it to process in the background.
    I told it to delete the rendered files when it was done.
    I ran the apple hardware Test from my Apple CD.
    I turned off the hard drive/screen 'sleep' settings.
    I switched the video format from NTSC to PAL.
    I swore and came up with multiple comically profane file names for the disk images.
    Nothing. It always gives the error following the 'processing menus' portion of the rendering.
    Facts:
    iBook G4
    1.2 GHz Power PC
    1.25 GB Ram
    41.77 Gigs of free hard drive on boot disk.
    iDVD v5.0.1 (625)
    iMovie HD v5.0.2 (111)
    Quicktime v7.1.5
    Mac OSX v10.4.9
    I'm running into a deadline and need to have this burned!!
    *** Mac?
    iBook G4   Mac OS X (10.4.9)   1.2 G Ram

    I switched the video format from NTSC to PAL.
    Why in the world would you do this? You are in the
    NTSC area. You must change the NTSC/PAL setting
    BEFORE you start a project.
    Mostly because I don't know what it means and wanted to try anything.
    All the video and audio is original content.
    I ended up going to the Mac genius bar today. They said that it was a corrupted encoding file solved by a reinstall of iDvd. Sounds like a lot of people run into this problem?
    On the topic of file formats... do you know why my titles look great in iMovie, but look like crap once I export them? Even if I export at "Full Quality". And is .dv better than .mpg4? I need a good primer.
    thanks,
    Ian
    I suspect the problem lies in your mpg-4 content.
    iMovie/iDVD have very spotty mpg-4 support. Try
    using something like VisualHub (
    http://www.techspansion.com/visualhub/ ) to convert
    your mpg-4 files to DV format. (You may also be
    having problems with the music used in your menus.
    Where does it come from?)
    F Shippey

  • Both side chatting with simple GUI ,,helps pls?

    guys I'm Java application programmer i don't have well knowledge in network programing ,,my question ,,,from where should i start to design a simple GUI client*s* server chat program ,i mean some thing like simple yahoo messenger the program should include also adding contact and make that contact appears ON if he login or OFF if he sign out like red color for ON-line contact and and white color for off-line contact ...........
    another thing that chat system should include shared folder all the contact can enter it and upload file or download file ...
    please guys i run to you to help me i have 2 weeks only to do that thing please don't let me down i need your help ....TIPS,code,any thing full code :) ,,any thing will be really appreciated .
    guys for more information the program includes only the chat of course its both sides chat between the clients and these is no conference room
    or audio or video nothing ,,just text only nothing else except the folder shearing service and the colors of the contacts for login or not .
    guys once more help me give me codes or any thing useful i count on you guys.
    thx a lot in advance
    RSPCPro
    Edited by: RSPCPRO on Oct 3, 2008 6:25 PM

    RSPCPRO wrote:
    Dude , u r right ,,,but still its simple GUI issueI'm not sure why you are getting this impression. It's not a simple "GUI issue." Yes, you can simply create the GUI for this, but will it be functional? No. Furthermore, if it was so simple, why are you posting asking for help?
    For an instant message chat program, in addition to GUI programming, you need to know how client / server systems work and you need to implement one. A server should be running on one system and the client(s) will connect to it. The server usually maintains the buddy list and passes the messages to/from different clients. This presents several problems that you will need to solve:
    1. How will you develop a protocol between the client / server for communication?
    2. How will you authenticate users?
    3. How will you maintain the buddy list on the server (data structure, database, file)?
    4. How will you pass messages from one client to another (simple string message, serialized data object, etc.)?
    5. etc.
    Now, I'm not saying this is "impossible" so please don't take it that way. I'm simply trying to help you realize that there are a lot of factors to consider when developing this type of application.
    RSPCPRO wrote:
    and for the "FTP?" ,,,its folder shearing as i said earlier every one of your friends can access it not FTP .....Talking about "folder sharing" is a whole other issue. What I meant by saying "FTP?" is, how do you plan on implementing "folder sharing" remotely? One option is FTP. How would you do it?
    RSPCPRO wrote:
    and one thing please don't assume any thing u don't knowIf you ask a very broad question and ask for code, I can only assume one thing.
    RSPCPRO wrote:
    be cooler with others and u will get what u want.I agree. You should take your own advice. I'm not the one looking for help, you are.
    RSPCPRO wrote:
    thx dude for ur advice and for the link have a good day.You're welcome, and good luck.

  • Simple viewer help

    Hi all, I need your help. I have created my website, and I'm linking it to mobile me galleries. (no problem). But-- instead of mobile me galleries I would like to link to Simple Viewer.
    No problem creating the SV galleries in iphoto , but getting them on my site is baffeling.
    I have read all the posts, and have had no success. I am a novice and the nominclature is rough
    As I said , I created the gallery folder and placed it in the sites folder on my idisk. when I click on the index folder within the gallery appears and the address is file:///Volumes/rgardnerimages/Web/Sites/slideshoe/index.html nothing I do is linking it to a web page. Any help in simple language would be helpful.
    My website is http://www.richardgardnerphotography.com/RichardGardner/richard_gardnerhome.html
    Thanks in advance
    Richard

    Its so long since I did this that I to look back and see where my files were uploaded and how they are organized.
    Its seems I have the following files uploaded to the main folder on my server:
    flash_detect.js
    image data.xml
    images
    PostCard.html
    thumbs
    viewer.swf
    PostCard.html is the index.html file renamed so that it doesn't conflict with the index.html file generated by iWeb.
    If you are using MobileMe to publish you can upload these files to the Finder/Go/iDisk/My iDisk/Web/Sites folder and the URL will be..
    http://web.me.com/username/PostCard.html
    Its probably better to upload them to your website folder. The path is Finder/Go/iDisk/My iDisk/Web/Sites/WebsiteName folder and the URL for the link to it will be ....
    http://web.me.com/username/WebsiteName/PostCard.html
    These uploads are done by drag and drop. Follow the path from the Finder/Go menu or do Shift - Command - I from any Finder window and then double click the Web then the Sites folders to get to your actual website folder.

Maybe you are looking for

  • Problems swapping external displays

    I use my MacBookPro with two external displays (not simultaneously), with the MBP lid shut. I have an Apple 20" cinema dispay in the office and an Acer (can't remember the model) at home. When I take my MBP home and plug it into the Acer the MBP does

  • My iMac with Comcast is suddenly extremely slow

    Suddenly my imac with comcast internet with apple airport is extremly slow. This sort of came out of the blue. I have called Comcast and they said everything on their end seems to check out fine. Going a bit nuts here. Any ideas as to why this is hap

  • HT201263 how to fix error 9 for recovery

    How do I fix error (9) for recovery in i tunes?

  • TREX and ABAP-Client with SAP Web AS 6.40

    Hi! We want to use the TREX in order to enhance the performance of our own business object searches within our ABAP engine. Therefore I've heard that from ABAP we can use the TREX to search for business objects residing in SAP ABAP stack tables. Curr

  • Howto send a mail with 2 attachments

    hi experts, i have to realise the following scenario: - a customer sends us invoice-data via webservice - sap-pi has to copy the payload - sap-pi adds some default-values the new payload - at the end i have to send an email with the original payload