Commit de121fcb authored by Baptiste Fournier's avatar Baptiste Fournier

added repaint method to MonDessin

parent 794d8c57
No preview for this file type
No preview for this file type
......@@ -9,6 +9,9 @@ public class MonDessin extends JPanel {
Image myImage;
BufferedImage img = null;
Color rectangleColor = Color.red;
public MonDessin() {
try {
img = ImageIO.read(new File("logo-CS-blanc.png"));
......@@ -16,6 +19,11 @@ public class MonDessin extends JPanel {
}
}
public void changeColor(Color newcolor){
rectangleColor = newcolor;
this.repaint();
}
public MonDessin(LayoutManager layout) {
super(layout);
// TODO Auto-generated constructor stub
......@@ -35,4 +43,5 @@ public class MonDessin extends JPanel {
g.fillRect(10, 10, 600, 300);
g.drawImage(img, 20,20,null);
}
}
......@@ -13,11 +13,14 @@ public class TestSwing {
MainFrame.setPreferredSize(preferredSize);
MainFrame.setTitle("Graphisme avec Swing");
MainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MainFrame.pack();
MainFrame.setVisible(true);
MonDessin dessin = new MonDessin();
MainFrame.add(dessin);
MainFrame.pack();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment