From 5fb795df7362913db2d12dd530eef9f3c72a3216 Mon Sep 17 00:00:00 2001 From: Fastium <79766552+Fastium@users.noreply.github.com> Date: Thu, 19 May 2022 09:36:10 +0200 Subject: [PATCH] comment on GUI exercice --- bin/GUI/ButtonListener.class | Bin 1126 -> 1126 bytes bin/GUI/GUI1.class | Bin 1320 -> 1320 bytes bin/GUI/GUI2.class | Bin 1497 -> 1497 bytes bin/GUI/Listener.class | Bin 1136 -> 1136 bytes src/GUI/GUI1.java | 19 +++++++++++++------ src/GUI/GUI2.java | 27 +++++++++++---------------- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/bin/GUI/ButtonListener.class b/bin/GUI/ButtonListener.class index 3bad10c31a9bf4a37a52af1729d3ea2658e9b860..5e05f10b4f4d65dc50e06084a721bccf6bd3a46f 100644 GIT binary patch delta 51 zcmaFH@r+|bH#4U(0}F!*11E#&Y+45kbU4CX*_D+WsjYX&z4+sURZ Fh5!>m2>t*7 diff --git a/bin/GUI/GUI1.class b/bin/GUI/GUI1.class index ed02c4ac1b8899d0c8947db351d86e70e731622d..095518a3ba30821e093acd33a4f12bb6e93dd9da 100644 GIT binary patch delta 290 zcmY+9y-LGS0ENHXCKfMIv{fr8txbPy)0#xBlY@w~qJ|1~3J8*+gIXGuXmRl+?n`tO zg*f;WzK)B=MRYl5_|AcICUPR5O(7+MqQM#^^(0z;nQDfLVD>6_2%KOXIS1h|yfdh= zF3=CpI-Q7RXaznK~=D qtg=Iqz2w^wCHk27l)0e7fGXEX>IRD$ppBmBEj>;XciC5;n*9yY1344` delta 292 zcmY+9%Syvg07TE##NZ_@we^K!tI@`o#KuQmxo{z^NJ9m?DhQHA7iwu#qQ&pXPju-6 z;=+&cf85mTMszd7a2S{w$&q}vgkw+hXCoa8 zSN=rXWD_U#h2M4Y4Lm{qw|*S=<9m~BY6AV_ywPY23gLfzDA{4pU{_H5Lk3B7HR!4G zKK1lPIB(v>r_ggukx$2y&4mxj-FH?)*UMOQGpes_Wd!Mk*6I|{m_brxmXg{%hs``5 qiyW}T5zCyiLPwD<6)v&psZTdlxm9O!KpkD_9c|8(+qBXzt@aIv$T`yh diff --git a/bin/GUI/GUI2.class b/bin/GUI/GUI2.class index 1924fb47fb828c9693791e3b6e221a8bd9f8f504..c550513a48821ae3974f5a5283042e921621c0f5 100644 GIT binary patch delta 57 zcmcb~eUp2G1FNne0}F#N10RD3g9L*pgDis>gF1sagARifgE@mVgAIcWg9lJFm_dOd LkwI~CE^7_|=Pd`0 delta 57 zcmcb~eUp2G1FNnm0}F!~10RDpg9H%DGDtG0Ge|M$Fvu{N19>(Kats~}@(jTYiVTSi JN|SS0a{%hX2de-8 diff --git a/bin/GUI/Listener.class b/bin/GUI/Listener.class index 180cf011281385d6a887c3d26cc210cf2552ef42..7e3c259461cf5eac2d4fe01068f9e7e0b5012072 100644 GIT binary patch delta 51 zcmeys@quH*5@t~=1{MZm22KWR20jKG24MzU1_=hc$vc@_cwHH|8Qd6@8QdB47(6F? Hv8Vw65u^!V delta 51 zcmeys@quH*5@u051{MZ022KWh20jJ{24MzA1_=hI$vc@_c)b|78N3;k8GIP@82l!C Hv8Vw66>$lR diff --git a/src/GUI/GUI1.java b/src/GUI/GUI1.java index bbefa25..04024be 100644 --- a/src/GUI/GUI1.java +++ b/src/GUI/GUI1.java @@ -8,36 +8,43 @@ import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; + +/** + * main class for create the window + */ public class GUI1 extends JFrame { public static void main(String[] args) { new GUI1(); } - GUI1(){ + //set up the window setTitle("Me"); setSize(200,200); setLocation(600,200); + this.getContentPane().setBackground(Color.GREEN); + //set the layout for the window FlowLayout fl = new FlowLayout(); this.setLayout(fl); - this.getContentPane().setBackground(Color.GREEN); - + //create and add component on the window JButton jb1 = new JButton("Foo"); JButton jb2 = new JButton("bar"); - ButtonListener bl = new ButtonListener(this); jb1.addActionListener(bl); jb2.addActionListener(bl); - - this.add(jb1); this.add(jb2); + this.setVisible(true); } } + +/** + * set up the class for detect button + */ class ButtonListener implements ActionListener{ JFrame f1; diff --git a/src/GUI/GUI2.java b/src/GUI/GUI2.java index c192df3..aad4fb6 100644 --- a/src/GUI/GUI2.java +++ b/src/GUI/GUI2.java @@ -7,57 +7,53 @@ import javax.swing.event.ChangeListener; import java.awt.Container; /** - * + * main class for create the window */ public class GUI2 extends JFrame{ int number; public static void main(String[] args) { new GUI2(); } - - /** - * - */ GUI2(){ + //set up the window with the layout setSize(200,200); setLocation(600,200); Container c = this.getContentPane(); BoxLayout fl = new BoxLayout(c, BoxLayout.Y_AXIS); c.setLayout(fl); + //create component on the window JSlider js1 = new JSlider(0, 100); js1.setValue(0); JProgressBar jp1 = new JProgressBar(0, 100); JLabel jl1 = new JLabel("waiting"); + //create the listener for the slider Listener l = new Listener(jp1, jl1, js1); js1.addChangeListener(l); + //addd component on the window c.add(js1); c.add(jp1); c.add(jl1); this.setVisible(true); } - - } /** - * + * class for detect slider mouvement */ class Listener implements ChangeListener { JProgressBar jp1; JLabel jl1; JSlider js1; - int number = 0; - /** - * - * @param jp1 - * @param jl1 - * @param js1 + * initialize the instance with parameters + * @param jp1 progress bar who display the number of the slider + * @param jl1 label progress bar who display the number of the slider + * @param js1 slider who modify the label and the progress bar */ Listener(JProgressBar jp1, JLabel jl1, JSlider js1){ this.jp1 = jp1; @@ -66,8 +62,7 @@ class Listener implements ChangeListener { } /** - * - * @param e + * modify the value of the label and the progress bar with the slider */ @Override public void stateChanged(ChangeEvent e) {