TP Exceptions
This commit is contained in:
38
DEV2.1/TP10/05_Degres/Degres.java
Normal file
38
DEV2.1/TP10/05_Degres/Degres.java
Normal file
@@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user