DEV/DEV3.1/Transitions/fenetre.java

89 lines
1.8 KiB
Java
Raw Normal View History

2023-09-20 12:11:33 +02:00
import java.awt.CardLayout;
import java.awt.BorderLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
public class fenetre extends JFrame implements MouseListener{
int imgN = 0;
String[] imgs = {"DEV3.1/Transitions/0495Snivy.png","DEV3.1/Transitions/0498Tepig.png","DEV3.1/Transitions/0501Oshawott.png"};
public fenetre()
{
super();
this.setSize(1000, 1000);
this.setLocation(0, 0);
this.add(new JLabel(new ImageIcon(this.imgs[this.imgN])),BorderLayout.CENTER);
addMouseListener(this);
}
public void next()
{
}
public void previous()
{
}
public void nextOld()
{
if (this.imgN+1>=imgs.length)
{
this.imgN = 0;
}
else
{
this.imgN++;
}
this.getContentPane().removeAll();
this.add(new JLabel(new ImageIcon(this.imgs[this.imgN])),BorderLayout.CENTER);
this.repaint();
this.revalidate();
}
public void previousOld()
{
if (this.imgN-1<0)
{
this.imgN = imgs.length-1;
}
else
{
this.imgN--;
}
this.getContentPane().removeAll();
this.add(new JLabel(new ImageIcon(this.imgs[this.imgN])),BorderLayout.CENTER);
this.repaint();
this.revalidate();
}
@Override
public void mouseClicked(MouseEvent e)
{
if (e.getX()<this.getWidth()/2)
{
this.previousOld();
}
else
{
this.nextOld();
}
}
@Override
public void mouseEntered(MouseEvent e) {}
@Override
public void mouseExited(MouseEvent e) {}
@Override
public void mousePressed(MouseEvent e) {}
@Override
public void mouseReleased(MouseEvent e) {}
}