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); } }