diff --git a/DEV.2.1/TP/TP8-Evenements/1.Fond/Fond.java b/DEV.2.1/TP/TP8-Evenements/1.Fond/Fond.java index 8250dee..b33bebe 100644 --- a/DEV.2.1/TP/TP8-Evenements/1.Fond/Fond.java +++ b/DEV.2.1/TP/TP8-Evenements/1.Fond/Fond.java @@ -1,11 +1,12 @@ import java.awt.*; import javax.swing.*; -public class Fond { +public class Fond extends JPanel implements ActionListener { private JButton Cyan, Magenta, Jaune; public Fond() { this.setLayout(null); + this.Cyan = new JButton("Cyan"); this.Magenta = new JButton("Magenta"); this.Jaune = new JButton("Jaune"); @@ -18,19 +19,19 @@ public class Fond { this.Magenta.addActionListener(this); this.Jaune.addActionListener(this); - frame.add(this.Cyan); - frame.add(this.Magenta); - frame.add(this.Jaune); + this.add(this.Cyan); + this.add(this.Magenta); + this.add(this.Jaune); } @Override public void actionPerformed(ActionEvent evenement) { if (evenement.getSource() == this.Cyan) { - frame.setBackground(Color.CYAN); + this.setBackground(Color.CYAN); } else if (evenement.getSource() == this.Magenta) { - frame.setBackground(Color.MAGENTA); + this.setBackground(Color.MAGENTA); } else if (evenement.getSource() == this.Jaune) { - frame.setBackground(Color.JAUNE); + this.setBackground(Color.YELLOW); } } } \ No newline at end of file diff --git a/DEV.2.1/TP/TP8-Evenements/1.Fond/MainFond.java b/DEV.2.1/TP/TP8-Evenements/1.Fond/MainFond.java index 6276079..29a9a37 100644 --- a/DEV.2.1/TP/TP8-Evenements/1.Fond/MainFond.java +++ b/DEV.2.1/TP/TP8-Evenements/1.Fond/MainFond.java @@ -9,32 +9,23 @@ public class MainFond { Fond panel = new Fond(); - frame.add(panel, BorderLayout.CENTER); + frame.add(panel); frame.setSize(500,500); frame.setLocation(500,250); frame.setVisible(true); } } -[srivasta@vm-srivasta 1.Fond]$ javac MainFond.java + +./Fond.java:4: error: cannot find symbol +public class Fond extends JPanel implements ActionListener { + ^ + symbol: class ActionListener ./Fond.java:27: error: cannot find symbol public void actionPerformed(ActionEvent evenement) { ^ symbol: class ActionEvent location: class Fond -MainFond.java:12: error: no suitable method found for add(Fond,String) - frame.add(panel, BorderLayout.CENTER); - ^ - method Container.add(String,Component) is not applicable - (argument mismatch; Fond cannot be converted to String) - method Container.add(Component,int) is not applicable - (argument mismatch; Fond cannot be converted to Component) - method Container.add(Component,Object) is not applicable - (argument mismatch; Fond cannot be converted to Component) -./Fond.java:8: error: cannot find symbol - this.setLayout(null); - ^ - symbol: method setLayout() ./Fond.java:17: error: incompatible types: Fond cannot be converted to ActionListener this.Cyan.addActionListener(this); ^ @@ -44,43 +35,38 @@ MainFond.java:12: error: no suitable method found for add(Fond,String) ./Fond.java:19: error: incompatible types: Fond cannot be converted to ActionListener this.Jaune.addActionListener(this); ^ -./Fond.java:21: error: cannot find symbol - frame.add(this.Cyan); - ^ - symbol: variable frame - location: class Fond -./Fond.java:22: error: cannot find symbol - frame.add(this.Magenta); - ^ - symbol: variable frame - location: class Fond -./Fond.java:23: error: cannot find symbol - frame.add(this.Jaune); - ^ - symbol: variable frame - location: class Fond ./Fond.java:26: error: method does not override or implement a method from a supertype @Override ^ -./Fond.java:29: error: cannot find symbol - frame.setBackground(Color.CYAN); - ^ - symbol: variable frame - location: class Fond -./Fond.java:31: error: cannot find symbol - frame.setBackground(Color.MAGENTA); - ^ - symbol: variable frame - location: class Fond ./Fond.java:33: error: cannot find symbol - frame.setBackground(Color.JAUNE); - ^ + setBackground(Color.JAUNE); + ^ symbol: variable JAUNE location: class Color -./Fond.java:33: error: cannot find symbol - frame.setBackground(Color.JAUNE); - ^ - symbol: variable frame - location: class Fond Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output -14 errors +7 errors +[srivasta@vm-srivasta 1.Fond]$ q +[srivasta@vm-srivasta 1.Fond]$ javac MainFond.java +./Fond.java:4: error: cannot find symbol +public class Fond extends JPanel implements ActionListener { + ^ + symbol: class ActionListener +./Fond.java:28: error: cannot find symbol + public void actionPerformed(ActionEvent evenement) { + ^ + symbol: class ActionEvent + location: class Fond +./Fond.java:18: error: incompatible types: Fond cannot be converted to ActionListener + this.Cyan.addActionListener(this); + ^ +./Fond.java:19: error: incompatible types: Fond cannot be converted to ActionListener + this.Magenta.addActionListener(this); + ^ +./Fond.java:20: error: incompatible types: Fond cannot be converted to ActionListener + this.Jaune.addActionListener(this); + ^ +./Fond.java:27: error: method does not override or implement a method from a supertype + @Override + ^ +Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output +6 errors