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 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;
public class Fenetre extends JFrame {
JPanel panel0 = new JPanel();
JPanel panel = new JPanel();
JPanel panel2 = new JPanel();
Border b = BorderFactory.createLineBorder(Color.black);
JLabel resultat = new JLabel("resultat");
Fenetre() {
this.setTitle("Calculatrice");
this.setVisible(true);
this.setSize(300, 300);
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
resultat.setBorder(b);
resultat.setBackground(Color.WHITE);
this.panel0.setPreferredSize(new Dimension(50, 50));
this.panel.setPreferredSize(new Dimension(100, 100));
this.panel2.setPreferredSize(new Dimension(50, 50));
this.getContentPane().add(resultat, BorderLayout.NORTH);
panel0.setLayout(new GridLayout(4, 1, 5, 5));
panel0.add(new JButton("1"));
panel0.add(new JButton("4"));
panel0.add(new JButton("7"));
panel0.add(new JButton("0"));
this.getContentPane().add(panel0, BorderLayout.WEST);
panel.setLayout(new GridLayout(4, 2, 5, 5));
panel.add(new JButton("2"));
panel.add(new JButton("3"));
panel.add(new JButton("5"));
panel.add(new JButton("6"));
panel.add(new JButton("8"));
panel.add(new JButton("9"));
panel.add(new JButton("."));
panel.add(new JButton("="));
this.getContentPane().add(panel, BorderLayout.CENTER);
panel2.setLayout(new GridLayout(5, 1,5, 5));
panel2.add(new JButton("c"));
panel2.add(new JButton("+"));
panel2.add(new JButton("-"));
panel2.add(new JButton("*"));
panel2.add(new JButton("/"));
this.getContentPane().add(panel2, BorderLayout.EAST);
}
} |
Partager