Como criar um pacote de imagens

1 resposta
N

e ai pessol... desenvolvi um aplicativo para loja de confecções calçados etc... e estou tentando fazer uma pequena animação usando duas fotos... tenho uma classe onde tudo indica que está correto... porem tenho que buscar as fotos em um pacote de imagens, e minha dúvida é se um pacote de imagens é somente uma pasta com as fotos dentro dela :oops:

essas são as classes de animação:

import javax.swing.JFrame; 

public class LogoAnimator 
{ 
public static void main( String args[] ) 
{ 
LogoAnimatorJPanel animation = new LogoAnimatorJPanel(); 

JFrame window = new JFrame( "Inter" ); 
window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); 
window.add( animation ); 

window.pack(); 
window.setVisible( true ); 

animation.startAnimation(); 
}

classeII

import java.awt.Dimension; 
import java.awt.event.ActionEvent; 
import java.awt.event.ActionListener; 
import java.awt.Graphics; 
import javax.swing.ImageIcon; 
import javax.swing.JPanel; 
import javax.swing.Timer; 

public class LogoAnimatorJPanel extends JPanel 
{ 
private final static String IMAGE_NAME = "teste"; 
protected ImageIcon images[]; 
private final int TOTAL_IMAGES = 1; 
private int currentImage = 0; 
private final int ANIMATION_DELAY = 50; 
private int width; 
private int height; 

private Timer animationTimer; 

public LogoAnimatorJPanel() 
{ 
images = new ImageIcon[ TOTAL_IMAGES ]; 

for ( int count = 0; count < images.length; count++ ) 
//AQUI ONDE BUSCA FOTOS NO PACOTE
images[count] = new ImageIcon(getClass().getResource("/R1.NET/R1.NET/images/" + IMAGE_NAME + count + ".PNG"));

width = images[ 0 ].getIconWidth(); 
height = images[ 0 ].getIconHeight(); 
} 

public void paintComponent( Graphics g ) 
{ 
super.paintComponent( g ); 

images[ currentImage ].paintIcon( this, g, 0, 0 ); 

if (animationTimer.isRunning()) 
currentImage = ( currentImage + 1 ) % TOTAL_IMAGES; 
} 

public void startAnimation() 
{ 
if ( animationTimer == null ) 
{ 
currentImage = 0; 

animationTimer = 
new Timer( ANIMATION_DELAY, new TimerHandler() ); 

animationTimer.start(); 
} 
else 
{ 
if ( ! animationTimer.isRunning()) 
animationTimer.restart(); 
} 
} 

public void stopAnimation() 
{ 
animationTimer.stop(); 
} 
public Dimension getMinimumSize() 
{ 
return getPreferredSize(); 
} 


public Dimension getPreferredSize() 
{ 
return new Dimension( width, height ); 
} 
private class TimerHandler implements ActionListener 
{ 
public void actionPerformed( ActionEvent actionEvent ) 
{ 
repaint(); 
} 
}

1 Resposta

N

ninguem!!!

Criado 26 de janeiro de 2011
Ultima resposta 26 de jan. de 2011
Respostas 1
Participantes 1