import java.awt.Color; import java.awt.Graphics; import javax.swing.*; public class GEOGraph extends JPanel { public void paintComponent( Graphics g ) { super.paintComponent( g ); this.setBackground( Color.WHITE ); g.setColor( Color.BLUE ); g.drawLine( 5, 30, 380, 30 ); //Dessiner une ligne g.setColor( Color.RED ); //Desssiner un Rectangle et modifier sa couleur de fond g.drawRect( 5, 40, 90, 55 ); g.fillRect( 100, 40, 90, 55 ); //Desssiner un Rectangle 3D et modifier sa couleur de fond g.setColor( Color.MAGENTA ); g.draw3DRect( 5, 100, 90, 55, true ); g.fill3DRect( 100, 100, 90, 55, false ); //Desssiner un Ovale et modifier sa couleur de fond g.setColor( Color.green ); g.drawOval( 195, 100, 90, 55 ); g.fillOval( 290, 100, 90, 55 ); } // Fonction principale public static void main (String[] args) { JFrame frame=new JFrame("Forme géométrique") ; JPanel policePanel=new GEOGraph(); frame.add(policePanel); frame.setSize(300,200); frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); frame.setVisible(true); } }