update
This commit is contained in:
@@ -5,6 +5,7 @@ public class Fond {
|
|||||||
private JButton Cyan, Magenta, Jaune;
|
private JButton Cyan, Magenta, Jaune;
|
||||||
|
|
||||||
public Fond() {
|
public Fond() {
|
||||||
|
this.setLayout(null);
|
||||||
this.Cyan = new JButton("Cyan");
|
this.Cyan = new JButton("Cyan");
|
||||||
this.Magenta = new JButton("Magenta");
|
this.Magenta = new JButton("Magenta");
|
||||||
this.Jaune = new JButton("Jaune");
|
this.Jaune = new JButton("Jaune");
|
||||||
@@ -12,5 +13,24 @@ public class Fond {
|
|||||||
this.Cyan.setBounds(100,50,100,20);
|
this.Cyan.setBounds(100,50,100,20);
|
||||||
this.Magenta.setBounds(220,50,100,20);
|
this.Magenta.setBounds(220,50,100,20);
|
||||||
this.Jaune.setBounds(320,50,100,20);
|
this.Jaune.setBounds(320,50,100,20);
|
||||||
|
|
||||||
|
this.Cyan.addActionListener(this);
|
||||||
|
this.Magenta.addActionListener(this);
|
||||||
|
this.Jaune.addActionListener(this);
|
||||||
|
|
||||||
|
frame.add(this.Cyan);
|
||||||
|
frame.add(this.Magenta);
|
||||||
|
frame.add(this.Jaune);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent evenement) {
|
||||||
|
if (evenement.getSource() == this.Cyan) {
|
||||||
|
frame.setBackground(Color.CYAN);
|
||||||
|
} else if (evenement.getSource() == this.Magenta) {
|
||||||
|
frame.setBackground(Color.MAGENTA);
|
||||||
|
} else if (evenement.getSource() == this.Jaune) {
|
||||||
|
frame.setBackground(Color.JAUNE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -6,9 +6,8 @@ public class MainFond {
|
|||||||
JFrame frame = new JFrame("Fond");
|
JFrame frame = new JFrame("Fond");
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
|
|
||||||
Fond test = new Fond();
|
Fond panel = new Fond();
|
||||||
|
|
||||||
frame.add(panel, BorderLayout.CENTER);
|
frame.add(panel, BorderLayout.CENTER);
|
||||||
frame.setSize(500,500);
|
frame.setSize(500,500);
|
||||||
@@ -16,3 +15,72 @@ public class MainFond {
|
|||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[srivasta@vm-srivasta 1.Fond]$ javac MainFond.java
|
||||||
|
./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(<null>)
|
||||||
|
./Fond.java:17: error: incompatible types: Fond cannot be converted to ActionListener
|
||||||
|
this.Cyan.addActionListener(this);
|
||||||
|
^
|
||||||
|
./Fond.java:18: error: incompatible types: Fond cannot be converted to ActionListener
|
||||||
|
this.Magenta.addActionListener(this);
|
||||||
|
^
|
||||||
|
./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);
|
||||||
|
^
|
||||||
|
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
|
||||||
|
Reference in New Issue
Block a user