Aidez moi en java
Résolu
bouchrot
Messages postés
351
Date d'inscription
Statut
Membre
Dernière intervention
-
bouchrot Messages postés 351 Date d'inscription Statut Membre Dernière intervention -
bouchrot Messages postés 351 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
salut nous avons commencer les interfaces graphiques en java ,donc j'ai fait un programme mais il ne m'affiche rien ,je ne sais pas pourquoi?
voila mon programme
public class Panneau extends JPanel{
public void paintComponent(Graphics g){
Graphics2D g2d = (Graphics2D)g;
GradientPaint gp, gp2, gp3, gp4, gp5, gp6;
gp = new GradientPaint(0, 0, Color.RED, 20, 0, Color.magenta, true);
gp2 = new GradientPaint(20, 0, Color.magenta, 40, 0, Color.blue, true);
gp3 = new GradientPaint(40, 0, Color.blue, 60, 0, Color.green, true);
gp4 = new GradientPaint(60, 0, Color.green, 80, 0, Color.yellow, true);
gp5 = new GradientPaint(80, 0, Color.yellow, 100, 0, Color.orange, true);
gp6 = new GradientPaint(100, 0, Color.orange, 120, 0, Color.red, true);
g2d.setPaint(gp);
g2d.fillRect(0, 0, 20, this.getHeight());
g2d.setPaint(gp2);
g2d.fillRect(20, 0, 20, this.getHeight());
g2d.setPaint(gp3);
g2d.fillRect(40, 0, 20, this.getHeight());
g2d.setPaint(gp4);
g2d.fillRect(60, 0, 20, this.getHeight());
g2d.setPaint(gp5);
g2d.fillRect(80, 0, 20, this.getHeight());
g2d.setPaint(gp6);
g2d.fillRect(100, 0, 40, this.getHeight());
}
public static void main(String[]args)
{
Panneau pan = new Panneau();
}
}
il m'affiche seulement :BUILD SUCCESSFUL
merci
salut nous avons commencer les interfaces graphiques en java ,donc j'ai fait un programme mais il ne m'affiche rien ,je ne sais pas pourquoi?
voila mon programme
public class Panneau extends JPanel{
public void paintComponent(Graphics g){
Graphics2D g2d = (Graphics2D)g;
GradientPaint gp, gp2, gp3, gp4, gp5, gp6;
gp = new GradientPaint(0, 0, Color.RED, 20, 0, Color.magenta, true);
gp2 = new GradientPaint(20, 0, Color.magenta, 40, 0, Color.blue, true);
gp3 = new GradientPaint(40, 0, Color.blue, 60, 0, Color.green, true);
gp4 = new GradientPaint(60, 0, Color.green, 80, 0, Color.yellow, true);
gp5 = new GradientPaint(80, 0, Color.yellow, 100, 0, Color.orange, true);
gp6 = new GradientPaint(100, 0, Color.orange, 120, 0, Color.red, true);
g2d.setPaint(gp);
g2d.fillRect(0, 0, 20, this.getHeight());
g2d.setPaint(gp2);
g2d.fillRect(20, 0, 20, this.getHeight());
g2d.setPaint(gp3);
g2d.fillRect(40, 0, 20, this.getHeight());
g2d.setPaint(gp4);
g2d.fillRect(60, 0, 20, this.getHeight());
g2d.setPaint(gp5);
g2d.fillRect(80, 0, 20, this.getHeight());
g2d.setPaint(gp6);
g2d.fillRect(100, 0, 40, this.getHeight());
}
public static void main(String[]args)
{
Panneau pan = new Panneau();
}
}
il m'affiche seulement :BUILD SUCCESSFUL
merci
A voir également:
- Aidez moi en java
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel - Télécharger - Jeux vidéo
- Eclipse java - Télécharger - Langages
- Java apk - Télécharger - Langages
- Waptrick java voiture - Télécharger - Jeux vidéo
2 réponses
C'est surtout qu'il te faudrait une fenetre, car cree un panneau c'est bien beau mais il faudrait peut etre que tu creer la fenetre avant et apres y integrer ton panneau.
Avec awt, on utilise une Frame
Avec awt, on utilise une Frame
public static void main(String[]args) { Panneau pan = new Panneau(); Frame f = new Frame (); f.setTitle ("Frame Example"); f.setSize (300,120); f.add(pan); f.setVisible(true); }
bouchrot
Messages postés
351
Date d'inscription
Statut
Membre
Dernière intervention
6
oui, c"est régler je te remercie