Probleme avec la fenetre et prog java
Fermé
cloclo
-
25 janv. 2010 à 14:15
elgammoudi Messages postés 3 Date d'inscription mercredi 7 avril 2010 Statut Membre Dernière intervention 9 avril 2010 - 9 avril 2010 à 22:10
elgammoudi Messages postés 3 Date d'inscription mercredi 7 avril 2010 Statut Membre Dernière intervention 9 avril 2010 - 9 avril 2010 à 22:10
A voir également:
- Probleme avec la fenetre et prog java
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel football - Télécharger - Jeux vidéo
- Java apk - Télécharger - Langages
- Waptrick java voiture - Télécharger - Jeux vidéo
- Fenêtre hors écran windows 11 - Guide
1 réponse
elgammoudi
Messages postés
3
Date d'inscription
mercredi 7 avril 2010
Statut
Membre
Dernière intervention
9 avril 2010
9 avril 2010 à 22:10
9 avril 2010 à 22:10
voila j'ai refaire ton travail et le changer un peut:
import java.awt.*;
class Fenetre extends Frame
{
public final static int HT = 300;
public final static int LG = 300;
public Fenetre(String s)
{
super(s);
Frame F = new Frame();
F.setSize(HT, LG); // taille de la fenetre
F.setBackground(Color.gray);
F.add(new forme());
F.setVisible(true); // affiche la fenetre
}
public static void main(String [] arg)
{
Fenetre f1=new Fenetre("Un triangle");
}
public class forme extends Canvas {
private Color couleur = Color.green;
public forme() {
setBackground(Color.white);
setForeground(couleur);
setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
}
public void paint (Graphics g) {
new Triangle(g);
}
public class Triangle {
private int centreX = Fenetre.HT/2;
private int centreY = Fenetre.LG/2;
private int [] xPoints = {centreX, centreX+10, centreX-10};
private int [] yPoints = {centreY-10, centreY+10, centreY+10};
private int nPoints = 3;
public Triangle(Graphics g) {
g.fillPolygon(xPoints, yPoints, nPoints);
}
}
}
}
import java.awt.*;
class Fenetre extends Frame
{
public final static int HT = 300;
public final static int LG = 300;
public Fenetre(String s)
{
super(s);
Frame F = new Frame();
F.setSize(HT, LG); // taille de la fenetre
F.setBackground(Color.gray);
F.add(new forme());
F.setVisible(true); // affiche la fenetre
}
public static void main(String [] arg)
{
Fenetre f1=new Fenetre("Un triangle");
}
public class forme extends Canvas {
private Color couleur = Color.green;
public forme() {
setBackground(Color.white);
setForeground(couleur);
setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
}
public void paint (Graphics g) {
new Triangle(g);
}
public class Triangle {
private int centreX = Fenetre.HT/2;
private int centreY = Fenetre.LG/2;
private int [] xPoints = {centreX, centreX+10, centreX-10};
private int [] yPoints = {centreY-10, centreY+10, centreY+10};
private int nPoints = 3;
public Triangle(Graphics g) {
g.fillPolygon(xPoints, yPoints, nPoints);
}
}
}
}