Solved

Animating pics for a splashpage

Posted on 2004-04-10
8
170 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 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now