Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Animated GIF display in JFrame vs. JApplet (http://www.velocityreviews.com/forums/t621985-animated-gif-display-in-jframe-vs-japplet.html)

Qu0ll 06-24-2008 12:17 PM

Animated GIF display in JFrame vs. JApplet
 
I have an animated GIF which I would like to display in all its animated
glory in a JFrame based application and in a JApplet. The GIF animates when
displayed in the JFrame by using the paintIcon() method of ImageIcon but the
same code only displays a static icon in the applet.

Is there a reason for this and/or a way to get it to work in the applet? I
am not trying to do anything sophisticated with it just yet, I simply create
a JPanel and override its paintComponent() method to paint the ImageIcon.
As I said, it works fine when the JPanel is in a JFrame but not in a
JApplet.

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour@gmail.com
[Replace the "SixFour" with numbers to email me]


Daniele Futtorovic 06-24-2008 06:38 PM

Re: Animated GIF display in JFrame vs. JApplet
 
On 2008-06-24 14:17 +0100, Qu0ll allegedly wrote:
> I have an animated GIF which I would like to display in all its animated
> glory in a JFrame based application and in a JApplet. The GIF animates
> when displayed in the JFrame by using the paintIcon() method of
> ImageIcon but the same code only displays a static icon in the applet.
>
> Is there a reason for this and/or a way to get it to work in the
> applet? I am not trying to do anything sophisticated with it just yet,
> I simply create a JPanel and override its paintComponent() method to
> paint the ImageIcon. As I said, it works fine when the JPanel is in a
> JFrame but not in a JApplet.
>


Simply put your Icon in a JLabel. Shouldn't be necessary to interfere
with paintComponent() at all.

This MAY solve your problem.


--
DF.
to reply privately, change the top-level domain
in the FROM address from "invalid" to "net"

Qu0ll 06-26-2008 09:40 AM

Re: Animated GIF display in JFrame vs. JApplet
 
"Daniele Futtorovic" <da.futt.news@laposte.invalid> wrote in message
news:g3repq$b9u$1@registered.motzarella.org...
> On 2008-06-24 14:17 +0100, Qu0ll allegedly wrote:
>> I have an animated GIF which I would like to display in all its animated
>> glory in a JFrame based application and in a JApplet. The GIF animates
>> when displayed in the JFrame by using the paintIcon() method of ImageIcon
>> but the same code only displays a static icon in the applet.
>>
>> Is there a reason for this and/or a way to get it to work in the applet?
>> I am not trying to do anything sophisticated with it just yet, I simply
>> create a JPanel and override its paintComponent() method to paint the
>> ImageIcon. As I said, it works fine when the JPanel is in a JFrame but
>> not in a JApplet.
>>

>
> Simply put your Icon in a JLabel. Shouldn't be necessary to interfere
> with paintComponent() at all.
>
> This MAY solve your problem.


Thanks but it just doesn't want to animate inside an applet even when in a
JLabel :-(

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour@gmail.com
[Replace the "SixFour" with numbers to email me]


Andrew Thompson 06-26-2008 11:47 AM

Re: Animated GIF display in JFrame vs. JApplet
 
On Jun 26, 7:40*pm, "Qu0ll" <Qu0llSixF...@gmail.com> wrote:
...
> > Simply put your Icon in a JLabel. ...


> Thanks but it just doesn't want to animate inside an applet even when in a
> JLabel :-(


Maybe your GIF is just tired. Try mine.
<http://pscode.org/test/animatedlabel/>

Interestingly, I tried that in a variety
of forms, and the first time I saw the GIF
animate in the applet was when it was coming
live off the net.

Are you testing off a file system, or server?

Have you searched the bug database for
'applet animated gif'?

--
Andrew Thompson
http://pscode.org/

Qu0ll 06-26-2008 01:00 PM

Re: Animated GIF display in JFrame vs. JApplet
 
"Andrew Thompson" <andrewthommo@gmail.com> wrote in message
news:71bd0699-9d1c-41b9-aa8b-cdff2daa0cd0@x19g2000prg.googlegroups.com...
> On Jun 26, 7:40 pm, "Qu0ll" <Qu0llSixF...@gmail.com> wrote:
> ...
>> > Simply put your Icon in a JLabel. ...

>
>> Thanks but it just doesn't want to animate inside an applet even when in
>> a
>> JLabel :-(

>
> Maybe your GIF is just tired. Try mine.
> <http://pscode.org/test/animatedlabel/>
>
> Interestingly, I tried that in a variety
> of forms, and the first time I saw the GIF
> animate in the applet was when it was coming
> live off the net.
>
> Are you testing off a file system, or server?


Just locally at this stage. I figured it wasn't going to work off a server
if it didn't work locally. I'll have to give it a try now.

> Have you searched the bug database for
> 'applet animated gif'?


Not yet.

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour@gmail.com
[Replace the "SixFour" with numbers to email me]


Andrew Thompson 06-26-2008 02:32 PM

Re: Animated GIF display in JFrame vs. JApplet
 
On Jun 26, 11:00*pm, "Qu0ll" <Qu0llSixF...@gmail.com> wrote:
> "Andrew Thompson" <andrewtho...@gmail.com> wrote in message

..
> > Are you testing off a file system, or server?

>
> Just locally at this stage. *


Tomcat can be good for local testing of applets.
...
> > Have you searched the bug database for
> > 'applet animated gif'?

>
> Not yet.


I vaguely recall hearing there was a problem with
animated GIFs that required establishing a Thread
to animate them. It was to do with paint() or
paintComponent() AFAIR, not specifically applets.

A quick search (of the net in general) failed to
turn up references to that.

--
Andrew Thompson
http://pscode.org/

Knute Johnson 06-26-2008 04:10 PM

Re: Animated GIF display in JFrame vs. JApplet
 
Qu0ll wrote:
> I have an animated GIF which I would like to display in all its animated
> glory in a JFrame based application and in a JApplet. The GIF animates
> when displayed in the JFrame by using the paintIcon() method of
> ImageIcon but the same code only displays a static icon in the applet.
>
> Is there a reason for this and/or a way to get it to work in the
> applet? I am not trying to do anything sophisticated with it just yet,
> I simply create a JPanel and override its paintComponent() method to
> paint the ImageIcon. As I said, it works fine when the JPanel is in a
> JFrame but not in a JApplet.
>


Please post the GIF or send it to me so I can try it.

Thanks,

--

Knute Johnson
email s/nospam/knute2008/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

Andrew Thompson 06-26-2008 11:05 PM

Re: Animated GIF display in JFrame vs. JApplet
 
On Jun 27, 2:10*am, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
...
> Please post the GIF or send it to me so I can try it.


Maybe the animated GIF I used for that example
will show the behavior for you. It is available
here.. <http://pscode.org/media/#image>

--
Andrew Thompson
http://pscode.org/

Knute Johnson 06-27-2008 04:36 AM

Re: Animated GIF display in JFrame vs. JApplet
 
Andrew Thompson wrote:
> On Jun 27, 2:10 am, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
> wrote:
> ...
>> Please post the GIF or send it to me so I can try it.

>
> Maybe the animated GIF I used for that example
> will show the behavior for you. It is available
> here.. <http://pscode.org/media/#image>


Andrew:

That GIF works fine. I tried my little program below on both Windows XP
and Fedora 9 using both the appletviewer and FireFox 3. I uploaded it
to my website and tried it from there as well. Under XP I tried it with
IE 7 and Opera as well. On XP I am using Sun's 6u10 compiler and
runtime. On F9 I'm using the default OpenJDK 1.6.0. I found no
problems displaying the animated GIF in an ImageIcon in a JLabel.

I did have some problems with the FireFox 3 cache that sent me round the
bend a few times however. That may or may not be the OP's problem. I
think I would still like to try his animated GIF.

http://rabbitbrush.frazmtn.com/atest.html

The JApplet (and yes I know I should really wrap the GUI code in an
EventQueue.invokeLater()).

import java.awt.*;
import java.awt.event.*;
import java.net.*;
import javax.swing.*;

public class atest extends JApplet {
public void init() {
try {
URL url = new URL(getCodeBase(),"starzoom-thumb.gif");
System.out.println(url);
ImageIcon ic = new ImageIcon(url);
JLabel l = new JLabel(ic);
add(l,BorderLayout.CENTER);
} catch (Exception e) {
e.printStackTrace();
}
}
}


The application

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class test extends JPanel {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ImageIcon ic = new ImageIcon("starzoom-thumb.gif");
JLabel l = new JLabel(ic);
f.add(l,BorderLayout.CENTER);
f.pack();
f.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}

--

Knute Johnson
email s/nospam/knute2008/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

Qu0ll 06-27-2008 07:05 AM

Re: Animated GIF display in JFrame vs. JApplet
 
"Knute Johnson" <nospam@rabbitbrush.frazmtn.com> wrote in message
news:48646e3e$0$4091$b9f67a60@news.newsdemon.com.. .
> Andrew Thompson wrote:
>> On Jun 27, 2:10 am, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
>> wrote:
>> ...
>>> Please post the GIF or send it to me so I can try it.

>>
>> Maybe the animated GIF I used for that example
>> will show the behavior for you. It is available
>> here.. <http://pscode.org/media/#image>

>
> Andrew:
>
> That GIF works fine. I tried my little program below on both Windows XP
> and Fedora 9 using both the appletviewer and FireFox 3. I uploaded it to
> my website and tried it from there as well. Under XP I tried it with IE 7
> and Opera as well. On XP I am using Sun's 6u10 compiler and runtime. On
> F9 I'm using the default OpenJDK 1.6.0. I found no problems displaying
> the animated GIF in an ImageIcon in a JLabel.
>
> I did have some problems with the FireFox 3 cache that sent me round the
> bend a few times however. That may or may not be the OP's problem. I
> think I would still like to try his animated GIF.
>
> http://rabbitbrush.frazmtn.com/atest.html
>
> The JApplet (and yes I know I should really wrap the GUI code in an
> EventQueue.invokeLater()).
>
> import java.awt.*;
> import java.awt.event.*;
> import java.net.*;
> import javax.swing.*;
>
> public class atest extends JApplet {
> public void init() {
> try {
> URL url = new URL(getCodeBase(),"starzoom-thumb.gif");
> System.out.println(url);
> ImageIcon ic = new ImageIcon(url);
> JLabel l = new JLabel(ic);
> add(l,BorderLayout.CENTER);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
>
>
> The application
>
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
>
> public class test extends JPanel {
> public static void main(String[] args) {
> EventQueue.invokeLater(new Runnable() {
> public void run() {
> try {
> JFrame f = new JFrame();
> f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> ImageIcon ic = new ImageIcon("starzoom-thumb.gif");
> JLabel l = new JLabel(ic);
> f.add(l,BorderLayout.CENTER);
> f.pack();
> f.setVisible(true);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> });
> }
> }


After a reworking of my applet I have it working fine now. It seems that I
may have been blocking the EDT inadvertently. False alarm.

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour@gmail.com
[Replace the "SixFour" with numbers to email me]



All times are GMT. The time now is 10:51 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.