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
| import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Tests extends JFrame{
JPanel panneau = new JPanel();
JLabel label = new JLabel();
JButton bouton = new JButton();
GridLayout GL = new GridLayout();
public Tests(){
this.setTitle("test");
this.setSize(300, 340);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
this.setLocationRelativeTo(null);
panneau.add(label);
panneau.setBackground(Color.LIGHT_GRAY);
GL.setColumns(5);
GL.setRows(5);
label.setText("0");
label.setHorizontalAlignment(JLabel.RIGHT);
label.setForeground(Color.CYAN);
label.setBackground(Color.MAGENTA);
panneau.add(new JButton("1")); panneau.add(new JButton("+"));
panneau.add(new JButton("2")); panneau.add(new JButton("-"));
panneau.add(new JButton("3")); panneau.add(new JButton("/"));
panneau.add(new JButton("4")); panneau.add(new JButton("*"));
panneau.add(new JButton("5")); panneau.add(new JButton("="));
panneau.add(new JButton("6")); panneau.add(new JButton("C"));
panneau.add(new JButton("7")); panneau.add(new JButton("."));
panneau.add(new JButton("8"));
panneau.add(new JButton("9"));
panneau.add(new JButton("0"));
this.setContentPane(panneau);
this.setVisible(true);
}
public static void main(String []args){
Tests t = new Tests();
}
} |
Partager