This commit is contained in:
2023-10-23 13:23:36 +02:00
parent 667dae6f1a
commit 322b22f9bf
5711 changed files with 72953 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DetectConvertion implements ActionListener{
private JTextField champsFarenheit;
private JTextField champsCelsius;
public DetectConvertion(JTextField champsFarenheit, JTextField champsCelsius){
this.champsFarenheit = champsFarenheit;
this.champsCelsius = champsCelsius;
}
@Override
public void actionPerformed(ActionEvent evenement){
JTextField source = (JTextField) evenement.getSource();
String valeurString = evenement.getActionCommand();
if (source == this.champsCelsius){
try{
double valeurDouble = Double.parseDouble(valeurString);
double resultat = valeurDouble*1.8+32;
this.champsFarenheit.setText(Double.toString(resultat));
}
catch(NumberFormatException erreur){
this.champsFarenheit.setText("???");
}
}
if (source == this.champsFarenheit){
try{
double valeurDouble = Double.parseDouble(valeurString);
double resultat = (valeurDouble-32)/1.8;
this.champsCelsius.setText(Double.toString(resultat));
}
catch(NumberFormatException erreur){
this.champsCelsius.setText("???");
}
}
}
}

View File

@@ -0,0 +1,20 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DetectConvertion implements ActionListener{
public JTextField champsFarenheit;
public JTextField champsCelsius;
public DetectConvertion(JTextField champsFarenheit, JTextField champsCelsius){
this.champsFarenheit = champsFarenheit;
this.champsCelsius = champsCelsius;
}
@Override
public void actionPerformed(ActionEvent evenement){
String valeur = evenement.getActionCommand();
this.champsCelsius.setText("");
this.champsFarenheit.setText(valeur);
}
}

View File

@@ -0,0 +1,18 @@
import javax.swing.*;
import java.awt.*;
public class Fond{
public static void main(String[] args) {
JButton boutonCyan = new JButton("Cyan");
JButton boutonMagenta = new JButton("Magenta");
JButton boutonJaune = new JButton("Jaune");
JButton[] boutonList = {boutonCyan,boutonMagenta,boutonJaune};
FondEvent fenetreClass = new FondEvent(boutonList);
fenetreClass.fenetre();
boutonCyan.addActionListener(fenetreClass);
boutonMagenta.addActionListener(fenetreClass);
boutonJaune.addActionListener(fenetreClass);
}
}

View File

@@ -0,0 +1,30 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FondEvent implements ActionListener{
public JPanel panneau;
public JTextField champsSaisis;
public FondEvent(JPanel contenu){
this.champsSaisis = new JTextField();
this.champsSaisis.setPreferredSize(new Dimension(200,20));
this.panneau = contenu;
this.panneau.add(this.champsSaisis);
}
@Override
public void actionPerformed(ActionEvent evenement){
String couleur = evenement.getActionCommand();
if (couleur.equals("Cyan")){
panneau.setBackground(Color.CYAN);
}
if (couleur.equals("Magenta")){
panneau.setBackground(Color.MAGENTA);
}
if (couleur.equals("Jaune")){
panneau.setBackground(Color.YELLOW);
}
this.champsSaisis.setText("");
}
}

View File

@@ -0,0 +1,30 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Q1Main{
public static void main(String[] args) {
JFrame fenetre = new JFrame();
fenetre.setSize(500, 300);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton boutonCyan = new JButton("Cyan");
JButton boutonMagenta = new JButton("Magenta");
JButton boutonJaune = new JButton("Jaune");
JPanel contenu = new JPanel();
contenu.add(boutonCyan);
contenu.add(boutonMagenta);
contenu.add(boutonJaune);
FondEvent evenementBouton = new FondEvent(contenu);
boutonCyan.addActionListener(evenementBouton);
boutonMagenta.addActionListener(evenementBouton);
boutonJaune.addActionListener(evenementBouton);
fenetre.add(contenu);
fenetre.setVisible(true);
}
}

Binary file not shown.

View File

@@ -0,0 +1,53 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Q5Main{
public static void main(String[] args) {
Color jaune = new Color(255,215,0);
JFrame fenetre = new JFrame("Degres");
fenetre.setSize(500, 300);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.setBackground(jaune);
JTextField champsCelsius = new JTextField();
JLabel texteCelsius = new JLabel("C");
JPanel LigneCelsius = new JPanel();
champsCelsius.setPreferredSize(new Dimension(300,20));
LigneCelsius.add(champsCelsius);
LigneCelsius.add(texteCelsius);
LigneCelsius.setBackground(jaune);
JTextField champsFarenheit = new JTextField();
JLabel texteFarenheit = new JLabel("F");
JPanel LigneFarenheit = new JPanel();
champsFarenheit.setPreferredSize(new Dimension(300,20));
LigneFarenheit.add(champsFarenheit);
LigneFarenheit.add(texteFarenheit);
LigneFarenheit.setBackground(jaune);
JPanel ensemble = new JPanel(new GridLayout(2,1));
ensemble.add(LigneCelsius);
ensemble.add(LigneFarenheit);
ensemble.setBackground(new Color(255,215,0));
fenetre.setBackground(jaune);
JPanel vide1 = new JPanel();
vide1.setBackground(jaune);
JPanel vide2 = new JPanel();
vide2.setBackground(jaune);
GridLayout grille = new GridLayout(3,1);
fenetre.setLayout(grille);
fenetre.add(vide1);
fenetre.add(ensemble);
fenetre.add(vide2);
DetectConvertion convertionObserveur = new DetectConvertion(champsFarenheit, champsCelsius);
champsCelsius.addActionListener(convertionObserveur);
champsFarenheit.addActionListener(convertionObserveur);
fenetre.setVisible(true);
}
}

View File

@@ -0,0 +1,52 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Q5Main{
public static void main(String[] args) {
Color jaune = new Color(255,215,0);
JFrame fenetre = new JFrame("Degres");
fenetre.setSize(500, 300);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.setBackground(jaune);
JTextField champsCelsius = new JTextField();
JLabel texteCelsius = new JLabel("C");
JPanel LigneCelsius = new JPanel();
champsCelsius.setPreferredSize(new Dimension(300,20));
LigneCelsius.add(champsCelsius);
LigneCelsius.add(texteCelsius);
LigneCelsius.setBackground(jaune);
JTextField champsFarenheit = new JTextField();
JLabel texteFarenheit = new JLabel("F");
JPanel LigneFarenheit = new JPanel();
champsFarenheit.setPreferredSize(new Dimension(300,20));
LigneFarenheit.add(champsFarenheit);
LigneFarenheit.add(texteFarenheit);
LigneFarenheit.setBackground(jaune);
JPanel ensemble = new JPanel(new GridLayout(2,1));
ensemble.add(LigneCelsius);
ensemble.add(LigneFarenheit);
ensemble.setBackground(new Color(255,215,0));
fenetre.setBackground(jaune);
JPanel vide1 = new JPanel();
vide1.setBackground(jaune);
JPanel vide2 = new JPanel();
vide2.setBackground(jaune);
GridLayout grille = new GridLayout(3,1);
fenetre.setLayout(grille);
fenetre.add(vide1);
fenetre.add(ensemble);
fenetre.add(vide2);
DetectConvertion convertionObserveur = new DetectConvertion(champsFarenheit, champsCelsius);
champsCelsius.addActionListener(convertionObserveur);
fenetre.setVisible(true);
}
}