diff --git a/bin/GUI/ButtonListener.class b/bin/GUI/ButtonListener.class index 3bad10c..5e05f10 100644 Binary files a/bin/GUI/ButtonListener.class and b/bin/GUI/ButtonListener.class differ diff --git a/bin/GUI/GUI1.class b/bin/GUI/GUI1.class index ed02c4a..095518a 100644 Binary files a/bin/GUI/GUI1.class and b/bin/GUI/GUI1.class differ diff --git a/bin/GUI/GUI2.class b/bin/GUI/GUI2.class index 1924fb4..c550513 100644 Binary files a/bin/GUI/GUI2.class and b/bin/GUI/GUI2.class differ diff --git a/bin/GUI/Listener.class b/bin/GUI/Listener.class index 180cf01..7e3c259 100644 Binary files a/bin/GUI/Listener.class and b/bin/GUI/Listener.class differ 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) {