diff --git a/DEV 3.1/TP2/Confirmation/Confirmation.java b/DEV 3.1/TP2/Confirmation/Confirmation.java new file mode 100644 index 0000000..d007018 --- /dev/null +++ b/DEV 3.1/TP2/Confirmation/Confirmation.java @@ -0,0 +1,39 @@ +import javax.swing.*; +import java.awt.*; + +public class Confirmation { + + private static String[] paths = { + "house", "info", "ok", "mail", "whatsapp" + }; + + private static CardLayout cards; + private static Container contentPane; + + public static void next() { + cards.next(contentPane); + } + + public static void previous() { + cards.previous(contentPane); + } + + public static void main(String[] args) { + JFrame window = new JFrame("GalerieAlt"); + window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + window.setSize(700, 700); + window.setLocation(200, 200); + window.addWindowListener(new ConfirmationWListener()); + window.setVisible(true); + + contentPane = window.getContentPane(); + cards = new CardLayout(); + contentPane.setLayout(cards); + + for (String path : paths) { + JLabel label = new JLabel(new ImageIcon("./images/" + path + ".png")); + label.addMouseListener(new ConfirmationMListener()); + contentPane.add(label, path); + } + } +} \ No newline at end of file diff --git a/DEV 3.1/TP2/Confirmation/ConfirmationMListener.java b/DEV 3.1/TP2/Confirmation/ConfirmationMListener.java new file mode 100644 index 0000000..fd7362d --- /dev/null +++ b/DEV 3.1/TP2/Confirmation/ConfirmationMListener.java @@ -0,0 +1,43 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class ConfirmationMListener implements MouseListener { + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + JLabel source = (JLabel)e.getSource(); + int x = e.getX(); + + if (x > source.getWidth() / 2) { + Confirmation.next(); + } else { + Confirmation.previous(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + +} diff --git a/DEV 3.1/TP2/Confirmation/ConfirmationWListener.java b/DEV 3.1/TP2/Confirmation/ConfirmationWListener.java new file mode 100644 index 0000000..8755fa9 --- /dev/null +++ b/DEV 3.1/TP2/Confirmation/ConfirmationWListener.java @@ -0,0 +1,75 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +/** + * GalleryWListener + */ +public class ConfirmationWListener implements WindowListener { + + @Override + public void windowActivated(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowClosed(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowClosing(WindowEvent e) { + JFrame window = (JFrame)e.getSource(); + JDialog d = new JDialog(window, true); + DialogListener dl = new DialogListener(d); + + d.setTitle("aRE U SUR"); + d.setSize(300, 200); + d.setLocation(500, 500); + d.setLayout(new GridLayout(1, 2)); + JButton yesBT = new JButton("Oui"); + yesBT.setName("Oui"); + yesBT.addMouseListener(dl); + JButton noBT = new JButton("Non"); + noBT.setName("Non"); + noBT.addMouseListener(dl); + + d.add(yesBT); + d.add(noBT); + d.setVisible(true); + + if (dl.getShouldClose()) { + window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } else { + window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + } + } + + @Override + public void windowDeactivated(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowDeiconified(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowIconified(WindowEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void windowOpened(WindowEvent e) { + // TODO Auto-generated method stub + + } + + +} \ No newline at end of file diff --git a/DEV 3.1/TP2/Confirmation/DialogListener.java b/DEV 3.1/TP2/Confirmation/DialogListener.java new file mode 100644 index 0000000..f9b18fe --- /dev/null +++ b/DEV 3.1/TP2/Confirmation/DialogListener.java @@ -0,0 +1,54 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class DialogListener implements MouseListener { + + private JDialog d; + private boolean shouldClose = false; + + public DialogListener(JDialog d) { + this.d = d; + } + + @Override + public void mouseClicked(MouseEvent e) { + Component c = (Component)e.getSource(); + + if (c.getName() == "Oui") { + shouldClose = true; + d.dispose(); + } else if (c.getName() == "Non") { + shouldClose = false; + d.dispose(); + } + } + + public boolean getShouldClose() { + return this.shouldClose; + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } +} diff --git a/DEV 3.1/TP2/Confirmation/images/house.png b/DEV 3.1/TP2/Confirmation/images/house.png new file mode 100644 index 0000000..a8a8581 Binary files /dev/null and b/DEV 3.1/TP2/Confirmation/images/house.png differ diff --git a/DEV 3.1/TP2/Confirmation/images/info.png b/DEV 3.1/TP2/Confirmation/images/info.png new file mode 100644 index 0000000..bd0170b Binary files /dev/null and b/DEV 3.1/TP2/Confirmation/images/info.png differ diff --git a/DEV 3.1/TP2/Confirmation/images/mail.png b/DEV 3.1/TP2/Confirmation/images/mail.png new file mode 100644 index 0000000..38c71ce Binary files /dev/null and b/DEV 3.1/TP2/Confirmation/images/mail.png differ diff --git a/DEV 3.1/TP2/Confirmation/images/ok.png b/DEV 3.1/TP2/Confirmation/images/ok.png new file mode 100644 index 0000000..5e2f0e4 Binary files /dev/null and b/DEV 3.1/TP2/Confirmation/images/ok.png differ diff --git a/DEV 3.1/TP2/Confirmation/images/whatsapp.png b/DEV 3.1/TP2/Confirmation/images/whatsapp.png new file mode 100644 index 0000000..4406b8a Binary files /dev/null and b/DEV 3.1/TP2/Confirmation/images/whatsapp.png differ diff --git a/DEV 3.1/TP2/Galerie/Galerie.class b/DEV 3.1/TP2/Galerie/Galerie.class new file mode 100644 index 0000000..7d38c05 Binary files /dev/null and b/DEV 3.1/TP2/Galerie/Galerie.class differ diff --git a/DEV 3.1/TP2/Galerie/Galerie.java b/DEV 3.1/TP2/Galerie/Galerie.java new file mode 100644 index 0000000..8449726 --- /dev/null +++ b/DEV 3.1/TP2/Galerie/Galerie.java @@ -0,0 +1,39 @@ +import javax.swing.*; +import java.awt.*; + +public class Galerie { + + private static String[] paths = { + "house", "info", "ok", "mail", "whatsapp" + }; + + private static int count = -1; + private static JLabel lb; + private static JFrame window; + + public static void update(boolean increment) { + count += increment ? 1 : -1; + if (count == -1) { + count = paths.length-1; + } + count %= paths.length; + + if (lb != null) window.remove(lb); + + String path = "./images/" + paths[count] + ".png"; + lb = new JLabel(new ImageIcon(path)); + lb.addMouseListener(new GalleryListener()); + window.add(lb, BorderLayout.CENTER); + window.revalidate(); + } + + public static void main(String[] args) { + window = new JFrame("Galerie"); + window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + window.setSize(650, 650); + window.setLocation(200, 200); + window.setVisible(true); + + Galerie.update(true); + } +} \ No newline at end of file diff --git a/DEV 3.1/TP2/Galerie/GalerieAlt.class b/DEV 3.1/TP2/Galerie/GalerieAlt.class new file mode 100644 index 0000000..51afc6e Binary files /dev/null and b/DEV 3.1/TP2/Galerie/GalerieAlt.class differ diff --git a/DEV 3.1/TP2/Galerie/GalerieAlt.java b/DEV 3.1/TP2/Galerie/GalerieAlt.java new file mode 100644 index 0000000..fdb77cd --- /dev/null +++ b/DEV 3.1/TP2/Galerie/GalerieAlt.java @@ -0,0 +1,38 @@ +import javax.swing.*; +import java.awt.*; + +public class GalerieAlt { + + private static String[] paths = { + "house", "info", "ok", "mail", "whatsapp" + }; + + private static CardLayout cards; + private static Container contentPane; + + public static void next() { + cards.next(contentPane); + } + + public static void previous() { + cards.previous(contentPane); + } + + public static void main(String[] args) { + JFrame window = new JFrame("GalerieAlt"); + window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + window.setSize(700, 700); + window.setLocation(200, 200); + window.setVisible(true); + + contentPane = window.getContentPane(); + cards = new CardLayout(); + contentPane.setLayout(cards); + + for (String path : paths) { + JLabel label = new JLabel(new ImageIcon("./images/" + path + ".png")); + label.addMouseListener(new GalleryAltListener()); + contentPane.add(label, path); + } + } +} \ No newline at end of file diff --git a/DEV 3.1/TP2/Galerie/GalleryAltListener.class b/DEV 3.1/TP2/Galerie/GalleryAltListener.class new file mode 100644 index 0000000..216061b Binary files /dev/null and b/DEV 3.1/TP2/Galerie/GalleryAltListener.class differ diff --git a/DEV 3.1/TP2/Galerie/GalleryAltListener.java b/DEV 3.1/TP2/Galerie/GalleryAltListener.java new file mode 100644 index 0000000..e2f9ebf --- /dev/null +++ b/DEV 3.1/TP2/Galerie/GalleryAltListener.java @@ -0,0 +1,43 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class GalleryAltListener implements MouseListener { + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + JLabel source = (JLabel)e.getSource(); + int x = e.getX(); + + if (x > source.getWidth() / 2) { + GalerieAlt.next(); + } else { + GalerieAlt.previous(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + +} diff --git a/DEV 3.1/TP2/Galerie/GalleryListener.class b/DEV 3.1/TP2/Galerie/GalleryListener.class new file mode 100644 index 0000000..eaced1b Binary files /dev/null and b/DEV 3.1/TP2/Galerie/GalleryListener.class differ diff --git a/DEV 3.1/TP2/Galerie/GalleryListener.java b/DEV 3.1/TP2/Galerie/GalleryListener.java new file mode 100644 index 0000000..664bbb5 --- /dev/null +++ b/DEV 3.1/TP2/Galerie/GalleryListener.java @@ -0,0 +1,39 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class GalleryListener implements MouseListener { + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + JLabel source = (JLabel)e.getSource(); + int x = e.getX(); + + Galerie.update(x > source.getWidth() / 2); + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + +} diff --git a/DEV 3.1/TP2/Galerie/images/house.png b/DEV 3.1/TP2/Galerie/images/house.png new file mode 100644 index 0000000..a8a8581 Binary files /dev/null and b/DEV 3.1/TP2/Galerie/images/house.png differ diff --git a/DEV 3.1/TP2/Galerie/images/info.png b/DEV 3.1/TP2/Galerie/images/info.png new file mode 100644 index 0000000..bd0170b Binary files /dev/null and b/DEV 3.1/TP2/Galerie/images/info.png differ diff --git a/DEV 3.1/TP2/Galerie/images/mail.png b/DEV 3.1/TP2/Galerie/images/mail.png new file mode 100644 index 0000000..38c71ce Binary files /dev/null and b/DEV 3.1/TP2/Galerie/images/mail.png differ diff --git a/DEV 3.1/TP2/Galerie/images/ok.png b/DEV 3.1/TP2/Galerie/images/ok.png new file mode 100644 index 0000000..5e2f0e4 Binary files /dev/null and b/DEV 3.1/TP2/Galerie/images/ok.png differ diff --git a/DEV 3.1/TP2/Galerie/images/whatsapp.png b/DEV 3.1/TP2/Galerie/images/whatsapp.png new file mode 100644 index 0000000..4406b8a Binary files /dev/null and b/DEV 3.1/TP2/Galerie/images/whatsapp.png differ