Solved

Animating pics for a splashpage

Posted on 2004-04-10
8
175 Views
Last Modified: 2010-03-31


How could 4 pics lined up in a row on a canvas or whatever move one pic from the row at a time moving from left to right into the background moving around and then bring them back into the row one at a time moving from right to left ending up where it started. It should be timed to complete itself in about 5 secs.

I want to have this as a splashpage for my program. I don't know how this need to be done.
0
Comment
Question by:Drop_of_Rain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 15

Expert Comment

by:Javatm
ID: 10798898
> How could 4 pics lined up in a row on a canvas or whatever move one pic from the row at a time.

This can be very tricky if you want to use java to handle this. As a suggestion just handle your animation
using animation programs like Macromedia fireworks, or flash or whatever animation tools that is
available for you and convert them into  GIF files.

After that thats the time you could call those GIF graphics into your splash screen

Here is the code for splash screen :

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

public class Splash extends JWindow {

 public MyScreen() {

  JLabel l1 = new JLabel(new ImageIcon("C:/YourFolder/YourPic.gif"));

  this.getContentPane().add(l1, BorderLayout.CENTER);

  // This is for the screen resolution and dimension
 
  Dimension sd  = Toolkit.getDefaultToolkit().getScreenSize();
  setLocation(sd.width / 2 - 300 / 2,
  sd.height / 2 - 200 / 2);

  setSize(300, 200);
  setVisible(true);

  int delay1 = 3000; //milliseconds

  ActionListener updater1 = new ActionListener() {
  public void actionPerformed(ActionEvent evt) {
  System.exit(0);
  }
  };

  new Timer(delay1, updater1).start();
  }

  public static void main( String args[] )
   {
      MyScreen app = new MyScreen();
   }
}

Hope that helps . . .
Javatm
0
 
LVL 15

Accepted Solution

by:
Javatm earned 250 total points
ID: 10798955
Sorry forgot to change so things :

/**
 * Created by : Javatm
 * Date  : 04/11/2004
 * Time : 7:27 AM
 */

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

public class Splash extends JWindow {

 public Splash() {

  JLabel l1 = new JLabel(new ImageIcon("C:/YourFolder/YourPic.gif"));

  this.getContentPane().add(l1, BorderLayout.CENTER);

  // This is for the screen resolution and dimension
 
  Dimension sd  = Toolkit.getDefaultToolkit().getScreenSize();
  setLocation(sd.width / 2 - 300 / 2,
  sd.height / 2 - 200 / 2);

  setSize(300, 200);
  setVisible(true);

  int delay1 = 3000; //milliseconds

  ActionListener updater1 = new ActionListener() {
  public void actionPerformed(ActionEvent evt) {
  System.exit(0);
  }
  };

  new Timer(delay1, updater1).start();
  }

  public static void main( String args[] )
   {
   Splash app = new Splash();
   }
}

Hope that helps . . .
Javatm
0
 
LVL 92

Assisted Solution

by:objects
objects earned 250 total points
ID: 10799412
Heres an article discussing how to animate an image:
http://www.javaworld.com/javaworld/jw-03-1996/jw-03-animation.html
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:Drop_of_Rain
ID: 10799784
Thanks for the code. I already had the splash page code. I'm going to leave this one open for a while
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10801509
You need to create a couple of things;
1. An Animator class
2. An AnimationPath class

The Animator class will have the information about frame rate, duration etc. and will ask registered UI elements to move according to the AnimationPath instance associated with it.

The AnimationPath class describes the path which an animated object should follow. It could also contain rotation information etc.
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10803957
import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

public class SplashPage extends JFrame
{
      private JLabel label1, label2, label3, label4;
      
      public SplashPage()
      {
            super();
            
            initialize();            
      }
      
      private void initialize()
      {
            JPanel panel = (JPanel)getContentPane();
            panel.setLayout(null);
            
            label1 = new JLabel("Image 1");
            //label1.setIcon(new ImageIcon("<file name with path>"));
            label1.setSize(100,100);
            label1.setLocation(10,10);
            label1.setBackground(Color.cyan);
            label1.setOpaque(true);
            
            panel.add(label1);

            label2 = new JLabel("Image 2");
            //label2.setIcon(new ImageIcon("<file name with path>"));
            label2.setSize(100,100);
            label2.setLocation(120,10);
            label2.setBackground(Color.gray);
            label2.setOpaque(true);
            
            panel.add(label2);

            label3 = new JLabel("Image 3");
            //label3.setIcon(new ImageIcon("<file name with path>"));
            label3.setSize(100,100);
            label3.setLocation(230,10);
            label3.setBackground(Color.magenta);
            label3.setOpaque(true);
            
            panel.add(label3);
            
            label4 = new JLabel("Image 4");
            //label4.setIcon(new ImageIcon("<file name with path>"));
            label4.setSize(100,100);
            label4.setLocation(340,10);
            label4.setBackground(Color.pink);
            label4.setOpaque(true);
            
            panel.add(label4);
            
            label1.setBorder(new LineBorder(Color.black));
            label2.setBorder(new LineBorder(Color.black));
            label3.setBorder(new LineBorder(Color.black));
            label4.setBorder(new LineBorder(Color.black));
            
            setSize(450, 300);
            setVisible(true);
            
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            
            new SplashThread();
      }
      
      class SplashThread extends Thread
      {
            public SplashThread()
            {
                  start();
            }
            
            public void run()
            {
                  JLabel label = null;
                  
                  for (int i = 0; i < 4; i++)
                  {
                        switch (i)
                        {
                              case 0:
                                    label = label1;
                                    break;
                                    
                              case 1:
                                    label = label2;
                                    break;
                                    
                              case 2:
                                    label = label3;
                                    break;            
                                    
                              case 3:
                                    label = label3;
                                    break;
                        }
                        
                        int startX = label.getX();
                        int startY = label.getY();
                        
                        for (int x = startX; x < 330; x += 10)
                        {
                              label.setLocation(x, startY);
                        }
                        
                        label.setLocation(startX, startY);
                  }
            }
      }
      
      public static void main(String[] args)
      {
            new SplashPage();
      }
}


This would help you having some idea on building the splash page


Regards,
Muruga
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question