This commit is contained in:
2023-09-27 17:28:01 +02:00
parent 0d553d9bfd
commit 4bbe6fa08a
9 changed files with 11 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
make :
javac -d build -cp build -sourcepath src src/fr/iutfbleau/but2/projet/galerie.java src/fr/iutfbleau//but
2/projet/fenetre.java

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

View File

@@ -0,0 +1,91 @@
package fr.iutfbleau.but2.projet;
import java.net.URL;
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;
ClassLoader loader = Thread.currentThread().getContextClassLoader();
URL[] imgs = {loader.getResource("res/0495Snivy.png"),loader.getResource("res/0498Tepig.png"),loader.getResource("res/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) {}
}

View File

@@ -0,0 +1,8 @@
package fr.iutfbleau.but2.projet;
public class galerie {
public static void main(String[] args) {
fenetre boum = new fenetre();
boum.setVisible(true);
}
}