Problems playing animated gif on label again

I have program that is displaying a graphic representation of a wave file this is a cut down of it. I am using a mouse listener to detect the mouse wheel and from that I am zooming in on the wave graphic or zooming out.
The problem is when I zoom in a Jlabel is displayed with an animated gif saying �zooming in� that work fine. But as soon as I zoom in again, the Jlabel will not display the image again or the zooming out image.
I an new to java so be kind to my code
Any help would be greatly appreciated
CODE
* DisWav1.java
* Created on 30 April 2006, 14:43
import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.util.Vector;
import javax.swing.JPanel;
import javax.swing.JDialog;
public class DisWav1 extends JDialog implements Runnable{
// varables
     private Thread thread;
     public static final int MAX_PRIORITY = 10;
     Vector lines = new Vector();
     Color jfcBlue = new Color(204, 204, 255);
Color pink = new Color(255, 175, 175);
private Font font12 = new Font("serif", Font.PLAIN, 12);
long mainSize = 36000;
int holdingArray[];
int ZOOMFactor;
     private JPanel jContentPane = null;
     * This is the default constructor
     public DisWav1() {
          super();
          initialize();
     * This method initializes this
     * @return void
     private void initialize() {
          this.setBackground(java.awt.Color.black);
          this.setContentPane(getJContentPane());
          this.setTitle("Display Wave");
this.setSize(150,150);
addMouseWheelListener(new java.awt.event.MouseWheelListener() {
public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
formMouseWheelMoved(evt);
     * This method initializes jContentPane
     * @return javax.swing.JPanel
     private JPanel getJContentPane() {
          if (jContentPane == null) {
               jContentPane = new JPanel();
               jContentPane.setBackground(java.awt.Color.black);
               jContentPane.setLayout(new BorderLayout());
          return jContentPane;
     public void run()
}// end run
public void start() {
thread = new Thread(this);
thread.setName("Display Graph");
thread.setPriority(MAX_PRIORITY );
thread.start();
}// end start
public void stop() {
if (thread != null) {
thread.interrupt();
thread = null;
}// end stop
// Create a array for drawing ines on screen in scale.
public void moveMe(int x, int y){
this.setLocation(x,y);
// used to detect when the mouse is wheel is move and then
// zoom IN or OUT
// also display jLabel with animated gif saying "zooming in" or "Zooming out"
private void formMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
javax.swing.JLabel zz;
zz = new javax.swing.JLabel();
zz.setBounds(this.getWidth()/2, this.getHeight()/2, 140,40);
zz.setText("");
getContentPane().add(zz);
int notches = evt.getWheelRotation();
if (notches < 0) {
getContentPane().add(zz);
zz.setIcon(new javax.swing.ImageIcon("zoomingin.gif"));
zz.setBounds(this.getWidth()/2-(zz.getWidth()/2), this.getHeight()/2-(zz.getHeight()/2), 140,40);
System.out.println("zoom up " + ZOOMFactor);
ZOOMFactor = ZOOMFactor +2;
} else {
if (ZOOMFactor <= 0 )
     ZOOMFactor = 1;
else{
getContentPane().add(zz);
zz.setIcon(new javax.swing.ImageIcon("C:zoomingOUT.gif"));
zz.setBounds(this.getWidth()/2-(zz.getWidth()/2), this.getHeight()/2-(zz.getHeight()/2), 140,40);
ZOOMFactor = ZOOMFactor - 2;
System.out.println("zoom down " + ZOOMFactor);
public void paint(Graphics g) {
// paints lines form a vector here on the screen
}// end of paint method
}// end class disWav1
// END CODE

think ive solved it

Similar Messages

  • Problem with animated .gif

    I have a problem with animated gifs. So if I set a animated gif as background and a button is over it as in the example below, then everytime the animation goes on the button disappears until I go over it with the mouse. So what can I do to solve this?
    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class FrameBackImage {
              public static void main(String args []){
                   final JFrame frame = new JFrame("Frame");
                   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   frame.setSize(400, 400);
                   frame.setResizable(false);
                   frame.setLayout(null);
                   java.net.URL imageURL = ImageApp.class.getResource("animatedw.gif");
                   ImageIcon imageIcon = new ImageIcon(imageURL);
                 final JLabel label = new JLabel(imageIcon);
                 label.setBounds(0,0 , 400, 400);
                 frame.getLayeredPane().add(label);
                 JButton button = new JButton ("Exit");
                 button.setBounds(200, 129, 60, 60);
                 button.setBackground(Color.black);
                 button.setForeground(Color.white);
                 frame.add(button);
                 button.addActionListener(
                 new ActionListener(){
                        public void actionPerformed(ActionEvent arg0) {
                             System.exit(0);
                 frame.validate();
                  frame.setVisible(true);
    }

    In the future, Swing related questions should be posted in the Swing forum.
    Your usage of the getLayeredPane() method is something I've never seen before, so I don't know if thats the problem or not.
    How to display a "background image" is asked all the time in the Swing forum. So to familiarize yourself with the forum you can try searching the Swing forum. Using the keywords I highlighted would be a good place to start.

  • Does the iPhone play animated GIFs?

    Hi,
    Does the iPhone play animated GIFs? Sorry for asking such a basic question but I can't seem to find the answer on the web or within this forum.
    Also how do you implement it into your code? Do you need to use a UIWebView or can you just declare it like a regular png or jpg (e.g. UIImage *image = [[UIImage imageNamed:@"photo.gif"])
    Thanks for any help.

    you can play gif in webView ,just the same way you load a jpeg or png..
    NSString *path = [[NSBundle mainBundle] pathForResource:@"santa" ofType:@"gif"];
    NSURL *url = [NSURL fileURLWithPath:path isDirectory:NO];
    /* Load the request. */
    [myWebView loadRequest:[NSURLRequest requestWithURL:url]];
    the gif that is locally saved will be loaded.

  • Problem saving animated gif

    Hello!
    Just for fun i was planning to edit a animated football tackle gif. I was planning to remove the player who tackle in each and every frame of the animated gif. So it would take some time to finish.
    I have successfully opened the gif in CS6 via import Video Frames to Layers.
    It consists of 72 layers and i have tried to fix 10 of them just to see how it roughly would look like.
    My problem comes when I try to save and render the GIF (via save for WEB).
    The 10 first frames of my gif only shows one freezing frame, and then it shows the rest from 11-72 without any problems.
    What am i doing wrong, since my edited layers don't show up in the final GIF?

    Right on! Easy solution.
    First, the reason your first 10 frames are not changing is because each of those frames shows the same layer (Layer 1).
    In your layers panel, you have Layer 1 set to visible and all the other layers are invisible. That's good for Frame 1, but for frame 2 you'll want to make Layer 2 the visible one.
    Click on Frame 2 in your Timeline panel and then check the eyeball icon to make Layer 2 visible! Do the same for Frame 3/Layer 3, Frame 4/Layer 4, etc. until you get to the end of the animation!
    To address the second problem, the option for Make Frames from Layers is greyed out because you already have frames in your timeline.
    Go to your Timeline panel and select all the frames and delete them.
    Then select all your layers in the Layer panel, right-click and choose Make Frames from Layers... you should be able to click on it once your Timeline is cleared. It will automatically create frames that go from Layer 1 to your last layer (so, you wouldn't have to do it manually like above ^).
    Either way should take care of your problem! Please let me know if this works for you!!
    Cheers,
    Michael

  • How do I stop playing animated GIF's within web pages?

    Various websites display numerous images available for download. Some of those images are animated GIF files. These files take time to load and chew up a lot of my limited upload/download usage. IE Explorer let me see a single image for the GIF but doesn't load or play the GIF. How do I get that same setting in Mozilla Fire Fox?

    hello vyoumans,
    i found a couple different ways this can be done.
    1. this firefox addon, [https://addons.mozilla.org/en-US/firefox/addon/toggle-animated-gifs/ Toggle animated GIFs], seems to work pretty good. ctrl+m toggles the animations on and off.
    2. if you don't want to install an addon, you can go to your browser configuration file. type ''about:config'' in the address bar and find the entry ''image.animation_mode''. double click it and set its value to ''none''. this should disable all GIF animations

  • Can the iPod (30 GB Video version) play animated .GIF files/pictures?

    When I go into the pictures folder, it only shows the first frame. Can it play animations?

    "Importing" .gif files is a very old QT Pro "trick" and was made available in the first "Pro" version of QT (3).
    I still use the feature to add logos or other, older animations to some of my newer QT "movies".
    Some of the older QT tricks can still be used today:
    http://homepage.mac.com/kkirkster/QT_Fun2/
    I've been focusing my skill (very little) on the QuickTime discussions pages but visit these "iPod" discussions pages every now and then.
    Since the new iPod can also "do" the .mov format I thought I'd observe and comment for the newer users.
    Happy New Year!
    Oh, btw, QuickTime can also do some magic with your Photoshop files.

  • Problems syncing animated gif files on website

    I am running Photoshop Elements 8 and have createdd a series of 7 animated gif files.  Within each of the 7 files consist of 4 layers(photos) with 5 second intervals in between each layer/photo.  Each of the 7 animated gif files have been uploaded to the home page of my website, all 7 animated gif files are set to 5 second intervals and also loop.  The problem occurs when either reloading or returning back to the home page, which causes the animated gif files to go out of sync, making it appear that each one of the 7 files are starting it's sequence at a different time.  My question is, how can I fix this issue?  I want all 7 animated gifs to start at exactly the same time, any suggestions?
    Thanks!

    Welcome to our community
    I'm not 100% sure on this but I believe you will need to convert the GIF to a SWF and insert it that way in order to preserve the animation.
    Click here to see a list of converters
    Cheers... Rick

  • Quality problem with animated gif through flash

    i got a problem with making animated gif through flash.
    on html/swf publication it looks clear.
    but the weird thing is through gif publication, it wouldn't show. and exporting it as a movie as gif cause visual defect when put up on web.
    it looks better when you open it in a browser.
    this is how it looks for a profile gif in thumbnail mode. blocky and unclear.
    how do you get it to look good both in thumbnail mode and in browser mode. i seen other that have a clear gif in thumbnail mode.  are my setting wrong for flash? or should i just do gif in photshop instead. i heard rumors flash don't do gif very well.

    Change your gif export setting under publish...
              Dimensions         : Match movie
              Playback             : Animated
                                        : Loop continuously
              Options               : Optimize colors
                                        : Smooth
              Transparent         : Opaque
              Dither                 : None
              Palette Type       : Adaptive
              Max colors         : 99999

  • Duration problem with animated gif

    Hi!
    I love the animated gif feature and have used it several times successfully.
    This time, it seems to ignoring my settings for duration. I've set the number as high as 1500/100, but when I preview in browser (Mac Safari or Firefox), the images just whip by. I did slice the animated area and optimize it as an animated gif and export it. When I worked with it again this morning, the first image reflected the 1500/100, but the rest are still racing. I've tried to attach file here.
    Also, I'm wondering if this really should be done in Flash rather than FW. The client wants maybe 5 or 6 images and with the 7 test I have now, I see we're at 216K file size. I don't know flash but if the blog theme we use doesn't have something set up, I assume I'll just outsource the Flash development.
    Thanks,
    Caryn

    Okay...it works for me, but....
    One thing to be careful of is saving vs. exporting. When you create your file, you should save it as a Fireworks .png document. Then, to produce your animated .gif, you should export it. I like using the Image Preview (under the File menu), as I can tweak any of the settings I want. Other people prefer the Export item and optimize their output.
    There are two kinds of .png files. A Fireworks .png has all the layers, vector shapes, Web layer, active filters, and special proprietary information that Fireworks uses. A flattened .png is just a bitmap, whether it has 32, 24, or 8 bits. There's no distinction between these files based on the extension. Another user once suggested using .fw.png for Fireworks documents and .png for exported .pngs and I found that a good suggestion.
    In any case, a good rule to follow is to use save when you want a Fireworks .png and export when you want a Web-ready bitmap of any format.
    So, this is my "but." I took your file and changed the durations of the other frames. I saved it as a Fireworks .png. I then went to File > Image Preview and selected Animated GIF as the format. From the Animation tab, I set the number of loops to 3 and exported. I then saved the .png again to store the loop information.
    Here's the .png (474k):
    Here's the animation (303k):
    Given that the .gif format does't have the colors to reproduce photographs well, I still recommend you look into image rotators. These are scripts that can cycle through a set of images. See this thread:
    http://forums.adobe.com/thread/518231?tstart=1

  • Safari 4: Problems with animated GIF

    Hi,
    since I've updated to Mac OS X 10.6 my Safari 4.0.3 has Problems with some animated GIF.
    Some of these smileys look strange.
    OS: Mac OS X 10.6.1
    Mac: iMac (24-inch Early 2008)

    HI,
    Apparently you aren't alone.
    http://discussions.apple.com/thread.jspa?messageID=10059219&#10059219
    Carolyn

  • Problems with animated gif with ftp publishing

    Hi
    I have successfully tested a site using mobile me. Ready to go online I uploaded it to an ftp host and the animated gifs are not animating, they appear static. Works fine on mobile me so the data is obviously correct. Anyone know why Im having this problem?

    think ive solved it

  • Playing animated GIFs with NetBeans

    Well for our Computer Science class we have to make a game.
    For our title screen we wanted an animated GIF to play.
    I made the animated GIF with Gimp and I am using the NetBeans IDE (I am using the GUI Builder)
    I have tried using the image as a JLabel but it didn't work.
    I just need it to play the GIF.
    Thanks.

    Ok sorry I should have posted some code.
    Also I got it to work. But I now have a new question.
    How do you loop the animation?
    Is it possible to layer a JButton on top of the GIF?
    And also is it possible to make this part of the code relative?
    Like can you make it where it looks through the entire file without a specific path.
    AndroidGIF.setIcon(new ImageIcon("C:\\Users\\***********\\Desktop\\android2.gif"));Here is the rest of my code.
    import javax.swing.*;
    class GIFTest extends JFrame
        JLabel AndroidGIF = new JLabel();
        public GIFTest()
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            AndroidGIF.setIcon(new ImageIcon("C:\\Users\\********\\Desktop\\android2.gif"));
            GroupLayout layout = new GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(27, 27, 27)
                    .addComponent(AndroidGIF)
                    .addContainerGap(41, Short.MAX_VALUE))
            layout.setVerticalGroup(
                layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(32, 32, 32)
                    .addComponent(AndroidGIF)
                    .addContainerGap(46, Short.MAX_VALUE))
            pack();
             public static void main(String args[])
                new GIFTest().setVisible(true);
    }Note that I bleeped out the name of the computer due to privacy.

  • Problem with animated gif when direct image sharing over iChat

    Im having an issue that an animated gif isnt displaying animated when I drag and drop it into an instant message window with a buddy. I drag it from Firefox animated into the chat window but its doesnt get animated. I can see his gifs are animated when he drags and drops it from Safari into the chat window. Does the internet browser make a difference, or is there an option I haven't turned on. I tried searching through the preferences and haven't got a clue to what's stopping my gifs from being animated during direct instant message session.
    Im using the latest iChat 5.0.3(745).

    Hi,
    Welcome to the    Discussions
    If you drag the pic to the Desktop (Download) and then drag to the Browser does it display as Animated then ?
    9:03 PM Sunday; December 12, 2010
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"

  • Transparency problem with animated gif within AJAX overlay

    Hello all,
    I have designed and animated a loading spinner in Photoshop CS3, which needs to sit within an Ajax overlay, with transparency set to 75.
    I tried exporting the spinner as an animated gif with a transparent background (using Save for Web), but it gave the animation a pixelated outside edge. Does anybody know how to remedy this?
    As the Ajax overlay is semi-transparent, I tried exporting the animated gif with a black background and transparency set to 75%. I ticked the transparency box in the export window, but once it is loading in the Ajax it doesn't seem to be transparent (see here: http://www.chrisgartside.co.uk/flash/Screenshot.jpg)
    Any help is very much appreciated.
    Best wishes,
    ruth.

    I forgot to mention that the Ajax pop-up is fired up from a Flash gaming applet.
    Thanks very much in advance.
    ruth.

  • Problems with animated gifs in Premiere Pro

    Hi everyone,
    I need some help with my video project - I made some animated gifs that I want to add to the end credits. Importing them etc. works just fine, but in the video, the images always show up with a white background (white "box" around the animted figure), although the gifs definitely have a transparent background to start with. If I import them e.g. as png stills, they are transparent.
    Am I doing something wrong? Or is that a Premiere thing&do I have to re-create the animations inside Premiere?
    I couldn't find anything on this in the forum and I am grateful for any help/suggestions!
    Thanks&have a great weekend!
    Patrick
    I am using Premiere Pro CS 5 on a Mac. The gifs were created in Photoshop.

    Welcome to the forum.
    When Still Images show as black, the first things that I investigate is the pixel x pixel dimensions of the images. With many Stills, even if they are within the allowed pixel x pixel range, one's computer's resources can be used up, and an alternate workflow might be useful - Scale the Images to match the Frame Size of the Sequence, prior to Import, in a program, like Photoshop. This ARTICLE might be helpful.
    The second thought is that the video driver is no longer performing properly, and needs to be updated. What is make/model of your graphics card, and what is the current number/date of your installed video driver?
    Good luck,
    Hunt

Maybe you are looking for