1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
class exemple extends JPanel {//implements Runnable {
JPanel bob = new JPanel();
int i = 5;
exemple(){
setLayout(new FlowLayout());
bob.setPreferredSize(new Dimension(300, 400));
add(bob);
//Thread travailleur = new Thread(this);
//travailleur.start();
}
public void paintComponent(Graphics g) {
//public void paint(Graphics g) {
super.paintComponent(g);
//super.paint(g);
//g = this.getGraphics();
g.drawString("BIENVENUE SUR YAM 1.0",10,50);
System.out.println("ok");
g.drawLine(150, 150, 175+i, 220);
g.drawLine(150, 150, 125+i, 220);
g.drawLine(150, 150, 150+i, 90);
g.drawOval(135, 60, 30+i, 30);
g.drawLine(150, 100, 165+i, 150);
g.drawLine(150, 100, 135+i, 150);
}
/*public void run(){
i += 5;
System.out.println("bonjour");
try {
Thread.sleep(1000);
} catch (InterruptedException exception) {
exception.printStackTrace();
}
repaint();
}*/
public static void main(String[] args) {
JFrame fenetre = new JFrame();
fenetre.setSize(300,300);
fenetre.setContentPane(new exemple());
fenetre.pack();
fenetre.setVisible(true);
}
} |
Partager