Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Animating pics for a splashpage

Posted on 2004-04-10
8
Medium Priority
?
176 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 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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.
Suggested Courses

715 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