Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.09 KB | None | 0 0
  1. package be.isims.ex2;
  2.  
  3. import javax.swing.*;
  4. import java.awt.*;
  5.  
  6. /**
  7.  * Created by flori on 19-06-17.
  8.  */
  9. public class Frame extends JFrame {
  10.  
  11.     //Instanciation des composants nécessaire
  12.     private JPanel container = new JPanel();
  13.     private JPanel premiereLigne = new JPanel();
  14.     private JPanel deuxLigne = new JPanel();
  15.     private JPanel troisiemeLigne = new JPanel();
  16.     private JPanel quatriemeLigne = new JPanel();
  17.     private JPanel cinquiemeLigne = new JPanel();
  18.  
  19.     //Premiere ligne
  20.     private JLabel lblMontant = new JLabel("Montant");
  21.     private JTextField txtMontant = new JTextField();
  22.  
  23.     //Seconde ligne
  24.     private JLabel lblCompte = new JLabel("Compte");
  25.     private JComboBox<String> listeCompte = new JComboBox<>();
  26.  
  27.     //troisième ligne
  28.     private JLabel lblTransaction = new JLabel("Transaction");
  29.     private JRadioButton rdDepot = new JRadioButton("Dépot");
  30.     private JRadioButton rdRetrait = new JRadioButton("Retrait");
  31.     private ButtonGroup btGroup = new ButtonGroup();
  32.  
  33.     //Quatrième ligne
  34.     private JButton btValider = new JButton("Valider");
  35.     private JButton btCalculer = new JButton("Calculer les intérets");
  36.  
  37.     //Cinquième ligne
  38.     private JTextField txt = new JTextField();
  39.     private JScrollPane scroll = new JScrollPane(txt);
  40.  
  41.     public Frame() {
  42.  
  43.         this.setTitle("MyBanking");
  44.         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  45.         this.setContentPane(container);
  46.         this.setVisible(true);
  47.         this.setLocationRelativeTo(null);
  48.         initComposants();
  49.         this.pack();
  50.     }
  51.  
  52.     public void initComposants() {
  53.  
  54.         //Placement des composants
  55.  
  56.         //Première ligne
  57.         premiereLigne.setLayout(new FlowLayout(FlowLayout.LEFT));
  58.         txtMontant.setPreferredSize(new Dimension(75, 25));
  59.         premiereLigne.add(lblMontant);
  60.         premiereLigne.add(txtMontant);
  61.  
  62.         //Deuxième ligne
  63.         deuxLigne.setLayout(new FlowLayout(FlowLayout.LEFT));
  64.         deuxLigne.add(lblCompte);
  65.         listeCompte.addItem("Compte Courant");
  66.         listeCompte.addItem("Compte Epargne");
  67.         deuxLigne.add(listeCompte);
  68.  
  69.         //Troisième ligne
  70.         troisiemeLigne.setLayout(new FlowLayout(FlowLayout.LEFT));
  71.         troisiemeLigne.add(lblTransaction);
  72.         btGroup.add(rdDepot);
  73.         btGroup.add(rdRetrait);
  74.         troisiemeLigne.add(rdDepot);
  75.         troisiemeLigne.add(rdRetrait);
  76.  
  77.         //Quatrième ligne
  78.         quatriemeLigne.setLayout(new FlowLayout(FlowLayout.LEFT));
  79.         quatriemeLigne.add(btValider);
  80.         quatriemeLigne.add(btCalculer);
  81.  
  82.         //Cinquième ligne
  83.         cinquiemeLigne.setLayout(new FlowLayout(FlowLayout.CENTER));
  84.         txt.setPreferredSize(new Dimension(200, 100));
  85.         cinquiemeLigne.add(scroll);
  86.  
  87.  
  88.         //Container
  89.         container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
  90.         container.add(premiereLigne);
  91.         container.add(deuxLigne);
  92.         container.add(troisiemeLigne);
  93.         container.add(quatriemeLigne);
  94.         container.add(cinquiemeLigne);
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement