tout court SVP où est le problème dans ce code par ce que même si je dessine dans Panel les formes n'apparaissent pas

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
56
57
58
 
import java.awt.*;
 
import javax.swing.*;
 
public class LinesRectsOvals extends JFrame {
 
	JPanel r2;
   // set window's title bar String and dimensions
   public LinesRectsOvals()
   {
      super( "Drawing lines, rectangles and ovals" );
 
      setSize( 400, 165 );
      setVisible( true );
      r2=new JPanel();
 
	    r2.setBounds(27, 37, 42,74);
	    r2.setLayout( new BorderLayout() );
	    add(r2);
 
 
   }
 
   // display various lines, rectangles and ovals
   public void paint( Graphics g )
   {
      r2.paint( g );  // call superclass's paint method
 
      g.setColor( Color.RED );
      g.drawLine( 5, 30, 90, 30 );
 
      g.setColor( Color.BLUE );
      g.drawRect( 5, 40, 90, 55 );
      g.fillRect( 100, 40, 90, 55 );
 
      g.setColor( Color.CYAN );
      g.fillRoundRect( 195, 40, 90, 55, 50, 50 );
      g.drawRoundRect( 290, 40, 90, 55, 20, 20 );
 
      g.setColor( Color.YELLOW );
      g.draw3DRect( 5, 100, 90, 55, true );
      g.fill3DRect( 100, 100, 90, 55, true );
 
      g.setColor( Color.MAGENTA );
      g.drawOval( 195, 100, 90, 55 );
      g.fillOval( 290, 100, 90, 55 );
 
   } // end method paint
 
   // execute application
   public static void main( String args[] )
   {
      LinesRectsOvals application = new LinesRectsOvals();
      application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
   }
 
}