Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package be.isims.ex2;
- import javax.swing.*;
- import java.awt.*;
- /**
- * Created by flori on 19-06-17.
- */
- public class Frame extends JFrame {
- //Instanciation des composants nécessaire
- private JPanel container = new JPanel();
- private JPanel premiereLigne = new JPanel();
- private JPanel deuxLigne = new JPanel();
- private JPanel troisiemeLigne = new JPanel();
- private JPanel quatriemeLigne = new JPanel();
- private JPanel cinquiemeLigne = new JPanel();
- //Premiere ligne
- private JLabel lblMontant = new JLabel("Montant");
- private JTextField txtMontant = new JTextField();
- //Seconde ligne
- private JLabel lblCompte = new JLabel("Compte");
- private JComboBox<String> listeCompte = new JComboBox<>();
- //troisième ligne
- private JLabel lblTransaction = new JLabel("Transaction");
- private JRadioButton rdDepot = new JRadioButton("Dépot");
- private JRadioButton rdRetrait = new JRadioButton("Retrait");
- private ButtonGroup btGroup = new ButtonGroup();
- //Quatrième ligne
- private JButton btValider = new JButton("Valider");
- private JButton btCalculer = new JButton("Calculer les intérets");
- //Cinquième ligne
- private JTextField txt = new JTextField();
- private JScrollPane scroll = new JScrollPane(txt);
- public Frame() {
- this.setTitle("MyBanking");
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setContentPane(container);
- this.setVisible(true);
- this.setLocationRelativeTo(null);
- initComposants();
- this.pack();
- }
- public void initComposants() {
- //Placement des composants
- //Première ligne
- premiereLigne.setLayout(new FlowLayout(FlowLayout.LEFT));
- txtMontant.setPreferredSize(new Dimension(75, 25));
- premiereLigne.add(lblMontant);
- premiereLigne.add(txtMontant);
- //Deuxième ligne
- deuxLigne.setLayout(new FlowLayout(FlowLayout.LEFT));
- deuxLigne.add(lblCompte);
- listeCompte.addItem("Compte Courant");
- listeCompte.addItem("Compte Epargne");
- deuxLigne.add(listeCompte);
- //Troisième ligne
- troisiemeLigne.setLayout(new FlowLayout(FlowLayout.LEFT));
- troisiemeLigne.add(lblTransaction);
- btGroup.add(rdDepot);
- btGroup.add(rdRetrait);
- troisiemeLigne.add(rdDepot);
- troisiemeLigne.add(rdRetrait);
- //Quatrième ligne
- quatriemeLigne.setLayout(new FlowLayout(FlowLayout.LEFT));
- quatriemeLigne.add(btValider);
- quatriemeLigne.add(btCalculer);
- //Cinquième ligne
- cinquiemeLigne.setLayout(new FlowLayout(FlowLayout.CENTER));
- txt.setPreferredSize(new Dimension(200, 100));
- cinquiemeLigne.add(scroll);
- //Container
- container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
- container.add(premiereLigne);
- container.add(deuxLigne);
- container.add(troisiemeLigne);
- container.add(quatriemeLigne);
- container.add(cinquiemeLigne);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement