473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Java applet with image effects, could you help me please

Hello everyone,

I've got a question about programming by using Java applet and the question is :
Design a web page containing an applet that simply switches from one image to the next with some transition effects such as :

Fade: Fade one image out while you fade the next one in.
Whirlpool fade: Building on the fade transition, rather than just fading between images the first image swirls out of focus; the swirl is then reversed and as it 'unswirls' the second image is revealed
Bathroom window fade: Again building on the fade transition, the image is broken up using a bathroom window effect, and as the effect is reversed the second image is revealed.


How to proceed

If you are unsure about how to tackle this exercise, then you may wish to break it down into smaller steps:
1.Create a basic web page with a static image
2.Replace the image with an applet that displays the image
3.Make the applet change between different images, and apply transitional effects to these changes.

Thanks in advance.
Oct 22 '06 #1
9 3219
r035198x
13,262 8TB
Hello everyone,

I've got a question about programming by using Java applet and the question is :
Design a web page containing an applet that simply switches from one image to the next with some transition effects such as :

Fade: Fade one image out while you fade the next one in.
Whirlpool fade: Building on the fade transition, rather than just fading between images the first image swirls out of focus; the swirl is then reversed and as it 'unswirls' the second image is revealed
Bathroom window fade: Again building on the fade transition, the image is broken up using a bathroom window effect, and as the effect is reversed the second image is revealed.


How to proceed

If you are unsure about how to tackle this exercise, then you may wish to break it down into smaller steps:
1.Create a basic web page with a static image
2.Replace the image with an applet that displays the image
3.Make the applet change between different images, and apply transitional effects to these changes.

Thanks in advance.
So where have you got so far? Were you able to create an html page with a picture on it? Were you able to make an applet that diplays a picture?
Oct 23 '06 #2
I do not need to make it with HTML
I need just to make applet that displays pictures with the effects in any Java software like “ Netbeans”

this is some example of the effects on the pictures.

http://www.ericharshbarger.org/cgi-bin/j.cgi?imagedissolve/index.html

http://www.ericharshbarger.org/cgi-bin/j.cgi?imagefade/index.html

http://www.ericharshbarger.org/cgi-bin/j.cgi?imagefan/index.html

*** make the effects together ****

Many Thanks in advance
Oct 24 '06 #3
r035198x
13,262 8TB
I do not need to make it with HTML
I need just to make applet that displays pictures with the effects in any Java software like “ Netbeans”

this is some example of the effects on the pictures.

http://www.ericharshbarger.org/cgi-bin/j.cgi?imagedissolve/index.html

http://www.ericharshbarger.org/cgi-bin/j.cgi?imagefade/index.html

http://www.ericharshbarger.org/cgi-bin/j.cgi?imagefan/index.html

*** make the effects together ****

Many Thanks in advance
You still have to write something first. Can you write an applet that displays an image?
Oct 24 '06 #4
You still have to write something first. Can you write an applet that displays an image?
Thank you for your answer .

the applet is something like that::

import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;


public class NewClass extends javax.swing.JApplet implements Runnable {
volatile Thread thread;

Image img;

public void ThreadApplet() {
}


public void init() {
try {
img = getImage(new URL(getDocumentBase(), "http://www.hi-seas.com/pics/pool3.jpg"));


} catch (Exception e) {
e.printStackTrace();
}
}
public void start()
{
Thread runThread = new Thread(this);
runThread.start();
}

public void stop()
{
thread = null;
}

public void run()
{
try
{
while (thread == Thread.currentThread())
{
repaint();
Thread.sleep(1000);
System.out.println("This is a thread");

}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void paint(Graphics g)
{
g.drawImage(img,10,10,this);
}


}
Oct 24 '06 #5
r035198x
13,262 8TB
Thank you for your answer .

the applet is something like that::

import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;


public class NewClass extends javax.swing.JApplet implements Runnable {
volatile Thread thread;

Image img;

public void ThreadApplet() {
}


public void init() {
try {
img = getImage(new URL(getDocumentBase(), "http://www.hi-seas.com/pics/pool3.jpg"));


} catch (Exception e) {
e.printStackTrace();
}
}
public void start()
{
Thread runThread = new Thread(this);
runThread.start();
}

public void stop()
{
thread = null;
}

public void run()
{
try
{
while (thread == Thread.currentThread())
{
repaint();
Thread.sleep(1000);
System.out.println("This is a thread");

}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void paint(Graphics g)
{
g.drawImage(img,10,10,this);
}


}
This will make it alternate between 2 images in the codebase

Expand|Select|Wrap|Line Numbers
  1. import java.awt.Graphics;
  2. import java.awt.Image;
  3. import java.net.URL;
  4.  
  5.  
  6. public class NewClass extends javax.swing.JApplet implements Runnable {
  7. Thread thread;
  8.  
  9. Image img;
  10.  
  11. public void ThreadApplet() {
  12. }
  13.  
  14.  
  15. public void init() {
  16. try {
  17.  
  18. img = getImage(new URL(getDocumentBase(), "Sample.jpg"));
  19.  
  20.  
  21. } catch (Exception e) {
  22. e.printStackTrace();
  23. }
  24. }
  25. public void start()
  26. {
  27. Thread runThread = new Thread(this);
  28. runThread.start();
  29. }
  30.  
  31.  
  32.  
  33. public void run()
  34. {
  35. try
  36. {
  37. while (true)
  38. {
  39.  
  40. img = getImage(new URL(getDocumentBase(), "sunlogo64x30.gif"));
  41. repaint();
  42. Thread.sleep(1000);
  43. getGraphics().clearRect(10, 10, img.getWidth(this), img.getHeight(this));
  44. repaint();
  45. img = getImage(new URL(getDocumentBase(), "Sample.jpg"));
  46. repaint();
  47. Thread.sleep(1000);
  48. getGraphics().clearRect(10, 10, img.getWidth(this), img.getHeight(this));
  49. System.out.println("This is a thread");
  50.  
  51. }
  52. }
  53. catch (Exception e)
  54. {
  55. e.printStackTrace();
  56. }
  57. }
  58. public void paint(Graphics g)
  59. {
  60. g.drawImage(img,10,10,this);
  61. }
  62.  
  63.  
  64. }
Oct 25 '06 #6
This will make it alternate between 2 images in the codebase

Expand|Select|Wrap|Line Numbers
  1. import java.awt.Graphics;
  2. import java.awt.Image;
  3. import java.net.URL;
  4.  
  5.  
  6. public class NewClass extends javax.swing.JApplet implements Runnable {
  7. Thread thread;
  8.  
  9. Image img;
  10.  
  11. public void ThreadApplet() {
  12. }
  13.  
  14.  
  15. public void init() {
  16. try {
  17.  
  18. img = getImage(new URL(getDocumentBase(), "Sample.jpg"));
  19.  
  20.  
  21. } catch (Exception e) {
  22. e.printStackTrace();
  23. }
  24. }
  25. public void start()
  26. {
  27. Thread runThread = new Thread(this);
  28. runThread.start();
  29. }
  30.  
  31.  
  32.  
  33. public void run()
  34. {
  35. try
  36. {
  37. while (true)
  38. {
  39.  
  40. img = getImage(new URL(getDocumentBase(), "sunlogo64x30.gif"));
  41. repaint();
  42. Thread.sleep(1000);
  43. getGraphics().clearRect(10, 10, img.getWidth(this), img.getHeight(this));
  44. repaint();
  45. img = getImage(new URL(getDocumentBase(), "Sample.jpg"));
  46. repaint();
  47. Thread.sleep(1000);
  48. getGraphics().clearRect(10, 10, img.getWidth(this), img.getHeight(this));
  49. System.out.println("This is a thread");
  50.  
  51. }
  52. }
  53. catch (Exception e)
  54. {
  55. e.printStackTrace();
  56. }
  57. }
  58. public void paint(Graphics g)
  59. {
  60. g.drawImage(img,10,10,this);
  61. }
  62.  
  63.  
  64. }

Thanks mate for your time and answer.

I tried with array of images and it is working probably.
But it is the first step in the program .
The second step is to do fade effect between images (3 images or 4 ,....)
Like this website

http://www.appletcollection.com/dissolveimage.html


****** the code of load array of images is *****

import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;


public class NewClass extends javax.swing.JApplet implements Runnable {
volatile Thread thread;

Image[] img = new Image[3];
Image image;
boolean stopped = false;


public void ThreadApplet() {
}


public void init() {
try {

for(int i=0;i<3;i++)
{
img[i] = getImage(getCodeBase(), i+1+".gif");
}

} catch (Exception e) {
e.printStackTrace();
}
}
public void start()
{
Thread runThread = new Thread(this);
runThread.start();
}

public void stop()
{
thread = null;
}

public void run()
{
try
{
int i=0;
while(!stopped)
{
image = img[i];
i = (++i)%3;
try
{
Thread.sleep(1000);
Thread.yield();
}
catch(Exception e)
{}
repaint();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}

public void paint(Graphics g)
{
g.drawImage(image,10,10,this);
}
}
Oct 25 '06 #7
r035198x
13,262 8TB
Thanks mate for your time and answer.

I tried with array of images and it is working probably.
But it is the first step in the program .
The second step is to do fade effect between images (3 images or 4 ,....)
Like this website

http://www.appletcollection.com/dissolveimage.html


****** the code of load array of images is *****

import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;


public class NewClass extends javax.swing.JApplet implements Runnable {
volatile Thread thread;

Image[] img = new Image[3];
Image image;
boolean stopped = false;


public void ThreadApplet() {
}


public void init() {
try {

for(int i=0;i<3;i++)
{
img[i] = getImage(getCodeBase(), i+1+".gif");
}

} catch (Exception e) {
e.printStackTrace();
}
}
public void start()
{
Thread runThread = new Thread(this);
runThread.start();
}

public void stop()
{
thread = null;
}

public void run()
{
try
{
int i=0;
while(!stopped)
{
image = img[i];
i = (++i)%3;
try
{
Thread.sleep(1000);
Thread.yield();
}
catch(Exception e)
{}
repaint();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}

public void paint(Graphics g)
{
g.drawImage(image,10,10,this);
}
}
Yeah second step is a bit tricky. I'll have a look at it just now and will keep you posted.
My first hunch is that we're going to need
MediaTracker, PixelGrabber and MemoryImageSource
Oct 25 '06 #8
i guess too late........
Oct 20 '07 #9
r035198x
13,262 8TB
i guess too late........
Yep, I guess that's one of those that got lost in a desert ...
Oct 22 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
3
by: Don | last post by:
Hi, I try to get a simple applet working, the class-file does load, but the image doesn't appear;( An error doesn't appear. The view is and stays 'grey' What I want: Automatic refresh of a...
2
by: Christian Galbavy | last post by:
Hy! My next problem is to make an applet from my program. I have just add the "extend applet" to my class and removed the main-method by the start-method of the applet. I was thinking that this...
2
by: Mark Richards | last post by:
An applet on one of my pages uses a big picture as background. I want to load it before the applet and the rest of the html source. By doing this I want to avoid that the pane of the applet is...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
1
by: dishal | last post by:
Can anyone help me please? How do I convert these codes to launch from a JFrame instead of a Java Applet? A simple program where the user can sketch curves and shapes in a variety of...
3
by: =?Utf-8?B?TWFya19C?= | last post by:
I recognize that this question has a substantial Java component and I have cross posted it on Sun’s website. But it is a problem of interface with VS.NET and I suspect they will angrily redirect...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.