diff --git a/DEV2.1/TP09/02_Playlist/Fenetre.class b/DEV2.1/TP09/02_Playlist/Fenetre.class index 0125b32..5d51810 100644 Binary files a/DEV2.1/TP09/02_Playlist/Fenetre.class and b/DEV2.1/TP09/02_Playlist/Fenetre.class differ diff --git a/DEV2.1/TP09/02_Playlist/Fenetre.java b/DEV2.1/TP09/02_Playlist/Fenetre.java index 240e8c3..9c3ea1e 100644 --- a/DEV2.1/TP09/02_Playlist/Fenetre.java +++ b/DEV2.1/TP09/02_Playlist/Fenetre.java @@ -2,33 +2,57 @@ import java.awt.*; import javax.swing.*; public class Fenetre extends JFrame { + + private JLabel2 actif; + private boolean estActif; + public Fenetre() { + this.estActif = false; this.setLocation(100, 100); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(new GridLayout(14, 1)); - JLabel[] chromakopia = { - new JLabel("St. Chroma"), - new JLabel("Rah Tah Tah"), - new JLabel("Noid"), - new JLabel("Darling, I"), - new JLabel("Hey Jane"), - new JLabel("I Killed You"), - new JLabel("Judge Judy"), - new JLabel("Sticky"), - new JLabel("Take Your Mask Off"), - new JLabel("Tomorrow"), - new JLabel("Thought I Was Dead"), - new JLabel("Like Him"), - new JLabel("Balloon"), - new JLabel("I Hope You Find Your Way Home") + JLabel2[] chromakopia = { + new JLabel2("St. Chroma"), + new JLabel2("Rah Tah Tah"), + new JLabel2("Noid"), + new JLabel2("Darling, I"), + new JLabel2("Hey Jane"), + new JLabel2("I Killed You"), + new JLabel2("Judge Judy"), + new JLabel2("Sticky"), + new JLabel2("Take Your Mask Off"), + new JLabel2("Tomorrow"), + new JLabel2("Thought I Was Dead"), + new JLabel2("Like Him"), + new JLabel2("Balloon"), + new JLabel2("I Hope You Find Your Way Home") }; - for (JLabel titre : chromakopia) { - this.addMouseListener(new GestionSouris(titre)); + for (JLabel2 titre : chromakopia) { + GestionSouris gestion = new GestionSouris(titre, this); + titre.addMouseListener(gestion); + titre.setGestionnaireSouris(gestion); this.add(titre); } this.pack(); } + + public boolean getEstActif() { + return this.estActif; + } + + public void setEstActif(boolean n) { + this.estActif = n; + } + + public void setActif(JLabel2 n) { + this.actif = n; + } + + public JLabel2 getActif() { + return this.actif; + } + } \ No newline at end of file diff --git a/DEV2.1/TP09/02_Playlist/GestionSouris.class b/DEV2.1/TP09/02_Playlist/GestionSouris.class index 3be87e7..f2c47ec 100644 Binary files a/DEV2.1/TP09/02_Playlist/GestionSouris.class and b/DEV2.1/TP09/02_Playlist/GestionSouris.class differ diff --git a/DEV2.1/TP09/02_Playlist/GestionSouris.java b/DEV2.1/TP09/02_Playlist/GestionSouris.java index 895b7dc..2c23b90 100644 --- a/DEV2.1/TP09/02_Playlist/GestionSouris.java +++ b/DEV2.1/TP09/02_Playlist/GestionSouris.java @@ -4,10 +4,14 @@ import java.awt.*; public class GestionSouris implements MouseListener { - private JLabel titre; + private JLabel2 titre; + private Fenetre fenetre; + private JLabel2 actif; + private boolean actuelEstActif; - public GestionSouris(JLabel titre) { + public GestionSouris(JLabel2 titre, Fenetre fenetre) { this.titre = titre; + this.fenetre = fenetre; } public void mouseClicked(MouseEvent evenement) { @@ -20,14 +24,35 @@ public class GestionSouris implements MouseListener { } public void mouseExited(MouseEvent evenement){ - this.titre.setOpaque(true); - this.titre.setBackground(Color.WHITE); - this.titre.repaint(); + if (!this.actuelEstActif) { + this.titre.setOpaque(true); + this.titre.setBackground(null); + this.titre.repaint(); + } + else { + this.titre.setBackground(Color.LIGHT_GRAY); + this.titre.repaint(); + } } public void mousePressed(MouseEvent evenement){ - } + this.titre.setBackground(Color.LIGHT_GRAY); + this.actuelEstActif = true; + this.titre.repaint(); + + if (this.fenetre.getEstActif()) { + this.fenetre.getActif().setBackground(null); + this.fenetre.getActif().getGestionnaireSouris().setActuelEstActif(false); + this.fenetre.getActif().repaint(); + } + this.fenetre.setEstActif(true); + this.fenetre.setActif(this.titre); + } public void mouseReleased(MouseEvent evenement){ } + + public void setActuelEstActif(boolean n) { + this.actuelEstActif = n; + } } \ No newline at end of file diff --git a/DEV2.1/TP09/02_Playlist/JLabel2.class b/DEV2.1/TP09/02_Playlist/JLabel2.class new file mode 100644 index 0000000..f53a08a Binary files /dev/null and b/DEV2.1/TP09/02_Playlist/JLabel2.class differ diff --git a/DEV2.1/TP09/02_Playlist/JLabel2.java b/DEV2.1/TP09/02_Playlist/JLabel2.java new file mode 100644 index 0000000..fe47109 --- /dev/null +++ b/DEV2.1/TP09/02_Playlist/JLabel2.java @@ -0,0 +1,19 @@ +import java.awt.*; +import javax.swing.*; +import java.awt.event.*; + +public class JLabel2 extends JLabel { + private GestionSouris gestionnaireSouris; + + public JLabel2(String s) { + super(s); + } + + public void setGestionnaireSouris(GestionSouris n) { + this.gestionnaireSouris = n; + } + + public GestionSouris getGestionnaireSouris() { + return this.gestionnaireSouris; + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/03_Rectangle/Fenetre.class b/DEV2.1/TP09/03_Rectangle/Fenetre.class new file mode 100644 index 0000000..6e120cc Binary files /dev/null and b/DEV2.1/TP09/03_Rectangle/Fenetre.class differ diff --git a/DEV2.1/TP09/03_Rectangle/Fenetre.java b/DEV2.1/TP09/03_Rectangle/Fenetre.java new file mode 100644 index 0000000..2c5916e --- /dev/null +++ b/DEV2.1/TP09/03_Rectangle/Fenetre.java @@ -0,0 +1,13 @@ +import java.awt.*; +import javax.swing.*; + +public class Fenetre extends JFrame { + public Fenetre() { + this.setSize(800, 500); + this.setLocation(100, 100); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + GestionSouris clicSouris = new GestionSouris(this); + this.addMouseListener(clicSouris); + this.addMouseMotionListener(new GestionMouvementSouris(this, clicSouris)); + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/03_Rectangle/GestionMouvementSouris.class b/DEV2.1/TP09/03_Rectangle/GestionMouvementSouris.class new file mode 100644 index 0000000..6921b15 Binary files /dev/null and b/DEV2.1/TP09/03_Rectangle/GestionMouvementSouris.class differ diff --git a/DEV2.1/TP09/03_Rectangle/GestionMouvementSouris.java b/DEV2.1/TP09/03_Rectangle/GestionMouvementSouris.java new file mode 100644 index 0000000..926a813 --- /dev/null +++ b/DEV2.1/TP09/03_Rectangle/GestionMouvementSouris.java @@ -0,0 +1,24 @@ +import java.awt.*; +import javax.swing.*; +import java.awt.event.*; + +public class GestionMouvementSouris implements MouseMotionListener { + + private Fenetre fenetre; + private GestionSouris clicSouris; + + public GestionMouvementSouris(Fenetre fenetre, GestionSouris clicSouris) { + this.fenetre = fenetre; + this.clicSouris = clicSouris; + } + + public void mouseDragged(MouseEvent e) { + System.out.println("Appuyé"); + this.clicSouris.setRect(e.getX(), e.getY()); + this.fenetre.repaint(); + } + + public void mouseMoved(MouseEvent e) { + System.out.println("Relâché"); + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/03_Rectangle/GestionSouris.class b/DEV2.1/TP09/03_Rectangle/GestionSouris.class new file mode 100644 index 0000000..1725e18 Binary files /dev/null and b/DEV2.1/TP09/03_Rectangle/GestionSouris.class differ diff --git a/DEV2.1/TP09/03_Rectangle/GestionSouris.java b/DEV2.1/TP09/03_Rectangle/GestionSouris.java new file mode 100644 index 0000000..96f1519 --- /dev/null +++ b/DEV2.1/TP09/03_Rectangle/GestionSouris.java @@ -0,0 +1,57 @@ +import java.awt.event.*; +import javax.swing.*; +import java.awt.*; + +public class GestionSouris implements MouseListener { + + private Fenetre fenetre; + private Rectangle rect; + private int debutX; + private int debutY; + private int finX; + private int finY; + + public GestionSouris(Fenetre fenetre) { + this.fenetre = fenetre; + } + + + public void mouseClicked(MouseEvent evenement) { + } + + public void mouseEntered(MouseEvent evenement){ + } + + public void mouseExited(MouseEvent evenement){ + } + + public void mousePressed(MouseEvent evenement){ + System.out.println("Appui simple"); + this.fenetre.add(new Rectangle(evenement.getX(), evenement.getY(), evenement.getX()+200, evenement.getY()+200)); + this.debutX = evenement.getX(); + this.debutY = evenement.getY(); + this.rect = new Rectangle(this.debutX, this.debutY, evenement.getX(), evenement.getY()); + //this.fenetre.add(rect); + this.fenetre.repaint(); + } + + public void mouseReleased(MouseEvent evenement){ + this.finX = evenement.getX(); + this.finY = evenement.getY(); + } + + public int getDebutX() { + return this.debutX; + } + + public int getDebutY() { + return this.debutY; + } + + public void setRect(int finX, int finY) { + this.rect.setBounds(this.debutX, this.debutY, finX, finY); + System.out.println("debut : [" + this.debutX + ", " + this.debutY + "]"); + System.out.println("fin : [" + finX + ", " + finY + "]"); + this.fenetre.repaint(); + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/03_Rectangle/Main.class b/DEV2.1/TP09/03_Rectangle/Main.class new file mode 100644 index 0000000..4bfefb8 Binary files /dev/null and b/DEV2.1/TP09/03_Rectangle/Main.class differ diff --git a/DEV2.1/TP09/03_Rectangle/Main.java b/DEV2.1/TP09/03_Rectangle/Main.java new file mode 100644 index 0000000..2768c3d --- /dev/null +++ b/DEV2.1/TP09/03_Rectangle/Main.java @@ -0,0 +1,6 @@ +public class Main { + public static void main(String[] args) { + Fenetre fenetre = new Fenetre(); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP09/03_Rectangle/Rectangle.class b/DEV2.1/TP09/03_Rectangle/Rectangle.class new file mode 100644 index 0000000..a36e131 Binary files /dev/null and b/DEV2.1/TP09/03_Rectangle/Rectangle.class differ diff --git a/DEV2.1/TP09/03_Rectangle/Rectangle.java b/DEV2.1/TP09/03_Rectangle/Rectangle.java new file mode 100644 index 0000000..a10f79c --- /dev/null +++ b/DEV2.1/TP09/03_Rectangle/Rectangle.java @@ -0,0 +1,29 @@ +import java.awt.*; +import javax.swing.*; + +public class Rectangle extends JComponent { + + private int departX; + private int departY; + private int finX; + private int finY; + + public Rectangle(int departX, int departY, int finX, int finY) { + this.departX = departX; + this.departY = departY; + this.finX = finX; + this.finY = finY; + } + + @Override + public void paintComponent(Graphics pinceau) { + Graphics secondPinceau = pinceau.create(); + if (this.isOpaque()) { + secondPinceau.setColor(this.getBackground()); + secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + + secondPinceau.setColor(Color.BLUE); + secondPinceau.fillRect(this.departX, this.departY, this.finX-this.departX, this.finY-this.departY); + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/01_Plantages/ArithmeticExceptionApplication.class b/DEV2.1/TP10/01_Plantages/ArithmeticExceptionApplication.class new file mode 100644 index 0000000..5942427 Binary files /dev/null and b/DEV2.1/TP10/01_Plantages/ArithmeticExceptionApplication.class differ diff --git a/DEV2.1/TP10/01_Plantages/ArithmeticExceptionApplication.java b/DEV2.1/TP10/01_Plantages/ArithmeticExceptionApplication.java new file mode 100644 index 0000000..ab9becd --- /dev/null +++ b/DEV2.1/TP10/01_Plantages/ArithmeticExceptionApplication.java @@ -0,0 +1,5 @@ +public class ArithmeticExceptionApplication { + public static void main(String[] args) { + System.out.println(15/0); + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/01_Plantages/ArrayIndexOutOfBoundsExceptionApplication.class b/DEV2.1/TP10/01_Plantages/ArrayIndexOutOfBoundsExceptionApplication.class new file mode 100644 index 0000000..887ea7c Binary files /dev/null and b/DEV2.1/TP10/01_Plantages/ArrayIndexOutOfBoundsExceptionApplication.class differ diff --git a/DEV2.1/TP10/01_Plantages/ArrayIndexOutOfBoundsExceptionApplication.java b/DEV2.1/TP10/01_Plantages/ArrayIndexOutOfBoundsExceptionApplication.java new file mode 100644 index 0000000..0f246cb --- /dev/null +++ b/DEV2.1/TP10/01_Plantages/ArrayIndexOutOfBoundsExceptionApplication.java @@ -0,0 +1,6 @@ +public class ArrayIndexOutOfBoundsExceptionApplication { + public static void main(String[] args) { + int[] tab = {4,5,8,2,9}; + System.out.println(tab[15]); + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/01_Plantages/NullPointerExceptionApplication.class b/DEV2.1/TP10/01_Plantages/NullPointerExceptionApplication.class new file mode 100644 index 0000000..26d9e17 Binary files /dev/null and b/DEV2.1/TP10/01_Plantages/NullPointerExceptionApplication.class differ diff --git a/DEV2.1/TP10/01_Plantages/NullPointerExceptionApplication.java b/DEV2.1/TP10/01_Plantages/NullPointerExceptionApplication.java new file mode 100644 index 0000000..1668f95 --- /dev/null +++ b/DEV2.1/TP10/01_Plantages/NullPointerExceptionApplication.java @@ -0,0 +1,9 @@ +public class NullPointerExceptionApplication { + + private int a; + + public static void main(String[] args) { + NullPointerExceptionApplication test = null; + test.a = 5; + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/01_Plantages/NumberFormatExceptionApplication.class b/DEV2.1/TP10/01_Plantages/NumberFormatExceptionApplication.class new file mode 100644 index 0000000..ff1ba25 Binary files /dev/null and b/DEV2.1/TP10/01_Plantages/NumberFormatExceptionApplication.class differ diff --git a/DEV2.1/TP10/01_Plantages/NumberFormatExceptionApplication.java b/DEV2.1/TP10/01_Plantages/NumberFormatExceptionApplication.java new file mode 100644 index 0000000..094cfb9 --- /dev/null +++ b/DEV2.1/TP10/01_Plantages/NumberFormatExceptionApplication.java @@ -0,0 +1,6 @@ +public class NumberFormatExceptionApplication { + public static void main(String[] args) { + String texte = "Bonjour"; + int nombre = Integer.parseInt(texte); + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/01_Plantages/RunTimeExceptionApplication.class b/DEV2.1/TP10/01_Plantages/RunTimeExceptionApplication.class new file mode 100644 index 0000000..5859086 Binary files /dev/null and b/DEV2.1/TP10/01_Plantages/RunTimeExceptionApplication.class differ diff --git a/DEV2.1/TP10/01_Plantages/RunTimeExceptionApplication.java b/DEV2.1/TP10/01_Plantages/RunTimeExceptionApplication.java new file mode 100644 index 0000000..b8123ef --- /dev/null +++ b/DEV2.1/TP10/01_Plantages/RunTimeExceptionApplication.java @@ -0,0 +1,5 @@ +public class RunTimeExceptionApplication { + public static void main(String[] args) { + throw new RuntimeException("Rip"); + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/02_Capture/ArithmeticExceptionApplication.class b/DEV2.1/TP10/02_Capture/ArithmeticExceptionApplication.class new file mode 100644 index 0000000..e5b4bdf Binary files /dev/null and b/DEV2.1/TP10/02_Capture/ArithmeticExceptionApplication.class differ diff --git a/DEV2.1/TP10/02_Capture/ArithmeticExceptionApplication.java b/DEV2.1/TP10/02_Capture/ArithmeticExceptionApplication.java new file mode 100644 index 0000000..f2153fc --- /dev/null +++ b/DEV2.1/TP10/02_Capture/ArithmeticExceptionApplication.java @@ -0,0 +1,16 @@ +public class ArithmeticExceptionApplication { + + public static int division(int a, int b) { + // En mettant l'exception ici, on option une ligne de plus à l'exécution + return a/b; + } + + public static void main(String[] args) { + try { + ArithmeticExceptionApplication.division(7, 0); + } catch (ArithmeticException e) { + System.out.println("Erreur : Division par 0"); + } + } + +} \ No newline at end of file diff --git a/DEV2.1/TP10/03_Incomplet/Incomplet.class b/DEV2.1/TP10/03_Incomplet/Incomplet.class new file mode 100644 index 0000000..ee73ab9 Binary files /dev/null and b/DEV2.1/TP10/03_Incomplet/Incomplet.class differ diff --git a/DEV2.1/TP10/03_Incomplet/Incomplet.java b/DEV2.1/TP10/03_Incomplet/Incomplet.java new file mode 100644 index 0000000..2225b40 --- /dev/null +++ b/DEV2.1/TP10/03_Incomplet/Incomplet.java @@ -0,0 +1,11 @@ +import java.io.IOException; + +public class Incomplet { + public static void main(String[] args) { + byte[] txt = {0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x0D, 0x0A}; + try { + System.out.write(txt); + } catch (IOException e) { + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/04_Apparences/Fond$1.class b/DEV2.1/TP10/04_Apparences/Fond$1.class new file mode 100644 index 0000000..60f51e1 Binary files /dev/null and b/DEV2.1/TP10/04_Apparences/Fond$1.class differ diff --git a/DEV2.1/TP10/04_Apparences/Fond$2.class b/DEV2.1/TP10/04_Apparences/Fond$2.class new file mode 100644 index 0000000..4c603fd Binary files /dev/null and b/DEV2.1/TP10/04_Apparences/Fond$2.class differ diff --git a/DEV2.1/TP10/04_Apparences/Fond$3.class b/DEV2.1/TP10/04_Apparences/Fond$3.class new file mode 100644 index 0000000..b3a67fe Binary files /dev/null and b/DEV2.1/TP10/04_Apparences/Fond$3.class differ diff --git a/DEV2.1/TP10/04_Apparences/Fond.class b/DEV2.1/TP10/04_Apparences/Fond.class new file mode 100644 index 0000000..7992d10 Binary files /dev/null and b/DEV2.1/TP10/04_Apparences/Fond.class differ diff --git a/DEV2.1/TP10/04_Apparences/Fond.java b/DEV2.1/TP10/04_Apparences/Fond.java new file mode 100644 index 0000000..08e9ac0 --- /dev/null +++ b/DEV2.1/TP10/04_Apparences/Fond.java @@ -0,0 +1,58 @@ +import java.awt.*; +import javax.swing.*; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +public class Fond { + public static void main(String[] args) { + try { + try { + UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); + } catch (ClassNotFoundException e) { + } + } catch (InstantiationException e2) { + } catch (IllegalAccessException e3) { + } catch (UnsupportedLookAndFeelException e4) { + } // On constate que les boutons changent d'apparence + catch (ClassCastException e5) { + System.out.println("Nom de manager incorrect"); + } // Les boutons restent comme avant + + JFrame fenetre = new JFrame(); + fenetre.setSize(300,200); + fenetre.setLocation(100,100); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + fenetre.setLayout(new GridLayout(1, 1)); + + JPanel panneau = new JPanel(); + + JButton bouton1 = new JButton("Cyan"); + JButton bouton2 = new JButton("Magenta"); + JButton bouton3 = new JButton("Jaune"); + + bouton1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evenement) { + panneau.setBackground(Color.CYAN); + } + }); + + bouton2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evenement) { + panneau.setBackground(Color.MAGENTA); + } + }); + + bouton3.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evenement) { + panneau.setBackground(Color.YELLOW); + } + }); + + panneau.add(bouton1); + panneau.add(bouton2); + panneau.add(bouton3); + + fenetre.add(panneau); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/05_Degres/Conversion.class b/DEV2.1/TP10/05_Degres/Conversion.class new file mode 100644 index 0000000..5fa4609 Binary files /dev/null and b/DEV2.1/TP10/05_Degres/Conversion.class differ diff --git a/DEV2.1/TP10/05_Degres/Conversion.java b/DEV2.1/TP10/05_Degres/Conversion.java new file mode 100644 index 0000000..c50f39e --- /dev/null +++ b/DEV2.1/TP10/05_Degres/Conversion.java @@ -0,0 +1,9 @@ +public class Conversion { + public static double celsiusAFahrenheit(double n) { + return n*9/5+32; + } + + public static double FahrenheitACelsius(double n) { + return (n-32)*5/9; + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/05_Degres/Degres.class b/DEV2.1/TP10/05_Degres/Degres.class new file mode 100644 index 0000000..cd43692 Binary files /dev/null and b/DEV2.1/TP10/05_Degres/Degres.class differ diff --git a/DEV2.1/TP10/05_Degres/Degres.java b/DEV2.1/TP10/05_Degres/Degres.java new file mode 100644 index 0000000..57f7b38 --- /dev/null +++ b/DEV2.1/TP10/05_Degres/Degres.java @@ -0,0 +1,38 @@ +import java.awt.*; +import javax.swing.*; +import javax.swing.event.*; +import java.awt.event.*; + +public class Degres extends JComponent { + + @Override + public void paintComponent(Graphics pinceau) { + Graphics secondPinceau = pinceau.create(); + + if (this.isOpaque()) { + secondPinceau.setColor(this.getBackground()); + secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + + secondPinceau.setColor(Color.ORANGE); + secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); + + JTextField celsius = new JTextField(); + JTextField fahrenheit = new JTextField(); + celsius.setBounds(0, 65, 160, 20); + fahrenheit.setBounds(0, 90, 160, 20); + + JLabel texteCelsius = new JLabel("°C"); + JLabel texteFahrenheit = new JLabel("°F"); + texteCelsius.setBounds(165, 65, 20, 20); + texteFahrenheit.setBounds(165, 90, 20, 20); + + celsius.getDocument().addDocumentListener(new GestionJTextField(celsius, fahrenheit, true)); + fahrenheit.getDocument().addDocumentListener(new GestionJTextField(fahrenheit, celsius, false)); + + this.add(celsius); + this.add(fahrenheit); + this.add(texteCelsius); + this.add(texteFahrenheit); + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/05_Degres/Fenetre.class b/DEV2.1/TP10/05_Degres/Fenetre.class new file mode 100644 index 0000000..a6ddeeb Binary files /dev/null and b/DEV2.1/TP10/05_Degres/Fenetre.class differ diff --git a/DEV2.1/TP10/05_Degres/Fenetre.java b/DEV2.1/TP10/05_Degres/Fenetre.java new file mode 100644 index 0000000..2f6377e --- /dev/null +++ b/DEV2.1/TP10/05_Degres/Fenetre.java @@ -0,0 +1,13 @@ +import java.awt.*; +import javax.swing.*; + +public class Fenetre extends JFrame { + public Fenetre() { + this.setSize(200, 200); + this.setLocation(100, 100); + this.setLayout(new GridLayout(1, 1)); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + Degres composant = new Degres(); + this.add(composant); + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/05_Degres/GestionJTextField.class b/DEV2.1/TP10/05_Degres/GestionJTextField.class new file mode 100644 index 0000000..74ba1b2 Binary files /dev/null and b/DEV2.1/TP10/05_Degres/GestionJTextField.class differ diff --git a/DEV2.1/TP10/05_Degres/GestionJTextField.java b/DEV2.1/TP10/05_Degres/GestionJTextField.java new file mode 100644 index 0000000..ab07d64 --- /dev/null +++ b/DEV2.1/TP10/05_Degres/GestionJTextField.java @@ -0,0 +1,46 @@ +import java.awt.event.*; +import java.awt.*; +import javax.swing.*; +import javax.swing.event.*; + +public class GestionJTextField implements DocumentListener { + + + private JTextField aConvertir; + private JTextField convertirVers; + private boolean cToF; + + public GestionJTextField(JTextField aConvertir, JTextField convertirVers, boolean cToF) { + this.aConvertir = aConvertir; + this.convertirVers = convertirVers; + this.cToF = cToF; + } + + + public void changedUpdate(DocumentEvent e) { + } + + + public void insertUpdate(DocumentEvent e) { + try { + if (this.cToF) { + this.convertirVers.setText(Conversion.celsiusAFahrenheit(Double.parseDouble(this.aConvertir.getText())) + ""); + } + else { + this.convertirVers.setText(Conversion.FahrenheitACelsius(Double.parseDouble(this.aConvertir.getText())) + ""); + } + } catch (NumberFormatException e2) { + try { + this.convertirVers.setText("???"); + } catch (IllegalStateException ee) { + } + } catch (IllegalStateException e3) { + } finally { + this.convertirVers.repaint(); + } + } + + + public void removeUpdate(DocumentEvent e) { + } +} \ No newline at end of file diff --git a/DEV2.1/TP10/05_Degres/Main.class b/DEV2.1/TP10/05_Degres/Main.class new file mode 100644 index 0000000..4bfefb8 Binary files /dev/null and b/DEV2.1/TP10/05_Degres/Main.class differ diff --git a/DEV2.1/TP10/05_Degres/Main.java b/DEV2.1/TP10/05_Degres/Main.java new file mode 100644 index 0000000..2768c3d --- /dev/null +++ b/DEV2.1/TP10/05_Degres/Main.java @@ -0,0 +1,6 @@ +public class Main { + public static void main(String[] args) { + Fenetre fenetre = new Fenetre(); + fenetre.setVisible(true); + } +} \ No newline at end of file