Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Animating pics for a splashpage

Posted on 2004-04-10
8
Medium Priority
?
177 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
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 1000 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 1000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn different types of Android Layout and some basics of an Android App.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

926 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