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 67 68
| package testgui;
import javax.swing.*;
import java.awt.*;
public class Fenetre extends JFrame {
private JTextField textbox1;
private JLabel sortie;
/////////////get/set textbox1
public JTextField getTextbox1() {
return textbox1;
}
public void setTextbox1(JTextField textbox1) {
this.textbox1 = textbox1;
}
///////////get/set label sortie
public JLabel getSortie() {
return sortie;
}
public void setSortie(int alpha) {
this.sortie = sortie;
}
public Fenetre() {
JButton button1 = new JButton("go");
textbox1 = new JTextField(20);
JTextField textbox2 = new JTextField(20);
JLabel label1 = new JLabel("x = ");
JLabel label2 = new JLabel("y = ");
sortie = new JLabel("");
JPanel panneau = new JPanel(null);
textbox1.setBounds(50, 50, 120, 30);
textbox2.setBounds(50, 100, 120, 30);
button1.setBounds(200, 65, 75, 35);
sortie.setBounds(100, 150, 60, 30);
label1.setBounds(30, 50, 60, 30);
label2.setBounds(30, 100, 60, 30);
panneau.add(sortie);
panneau.add(label1);
panneau.add(textbox1);
panneau.add(label2);
panneau.add(textbox2);
panneau.add(button1);
JFrame frame = new JFrame("Calculatrice");
frame.setContentPane(panneau);
frame.pack();
frame.setSize(360, 640);
frame.setVisible(true);
MoteurCalcul moteurCalcul = new MoteurCalcul(this);
button1.addActionListener(moteurCalcul);
}
public static void main(String[] args) {
Fenetre fenetre = new Fenetre();
}
} |
Partager