1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.GridLayout;
import java.awt.BorderLayout;
import java.awt.Container;
public class Main extends JFrame
{
private JTextField tc = new JTextField(5),
tf = new JTextField(5);
private JButton b1 = new JButton(" > "),
b2 = new JButton(" < ");
private JLabel lc = new JLabel("Degrés Celsius : "),
lf = new JLabel("Degrés Fahrenheit : ");
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
(new Main("Convertisseur de température")).setVisible(true);
}
public Main(String titre)
{
super(titre);
JPanel p1 = new JPanel(),
p2 = new JPanel(),
p3 = new JPanel(),
p2a = new JPanel(),
p2b = new JPanel();
p2.setLayout(new GridLayout(2,1));
p1.add(lc);
p1.add(tc);
p3.add(lf);
p3.add(tf);
p2a.add(b1);
p2b.add(b2);
p2.add(p2a);
p2.add(p2b);
Container coucheContenu = this.getContentPane();
coucheContenu.add(p1,BorderLayout.WEST);
coucheContenu.add(p2,BorderLayout.CENTER);
coucheContenu.add(p3,BorderLayout.EAST);
setSize(450,100);
setLocation(100,100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
} |
Partager