IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Collection et Stream Java Discussion :

Problème historisation d'images dans une ArrayList


Sujet :

Collection et Stream Java

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    47
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2006
    Messages : 47
    Par défaut Problème historisation d'images dans une ArrayList
    Bonjour à tous,

    Je crée actuellement un éditeur d'image en Java...
    Actuellement, il est possible de dessiner sur un panel avec la souris (comme on dessine sur une feuille avec un crayon)...Sur ce panel est dessinée une image qu'on peut éditer...Mon but final est de créer une sorte de "Paint"...

    Avant d'aller plus loin, je me suis dit qu'il serait bon d'implémenter les actions "Undo" et "Redo"...et c'est à ce niveau que j'ai actuellement un problème...

    Mon éditeur se compose actuellement de 3 classes :

    • DrawPanel.java

      Cette classe est un panel sur lequel on dessine des images (BufferedImage)...Les 2 champs principaux de cette classe sont :

      - "historic" : une ArrayList contenant des BufferedImage. ce champ permet de garder l'historique des modifications faites sur l'image.

      - "currentIndexImage" : index dans l'ArrayList de l'image courante .


    • ImageEditor.java
      Cette classe est une JFrame contenant le DrawPanel (voir ci-dessus), un JLabel donnant les coordonnées de la souris dans le DrawPanel, et les 2 boutons "Undo" et "Redo"...


    • Main.java
      Permet de lancer le programme


    Afin de cerner mon problème, je vous demande de lancer l'éditeur, de dessiner 3, 4 traits et d'utiliser les boutons undo et redo...Vous constaterez rapidemment qu'il est impossible de revenir à l'image initiale...et que lorsqu'on se trouve sur la dernière image, il faut cliquer deux fois sur "Undo" pour enlever la dernière modification...

    A première vue, ca a l'air d'un compteur qui s'incrémente ou se décrémente mal, mais je ne vois pas d'où vient mon erreur! Je vous joins donc le code des 3 classes ainsi qu'une image de Test...

    J'attends vos réponses avec impatience...Merci

    DrawPanel.java
    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Insets;
    import java.awt.Rectangle;
    import java.awt.image.BufferedImage;
    import java.util.ArrayList;
     
    import javax.swing.ImageIcon;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
     
    public class DrawPanel extends JPanel {
    	private static int currentIndexImage = 0;
     
        // Historic of the images
        private ArrayList<BufferedImage> historic = new ArrayList<BufferedImage>();
     
        private Dimension preferredSize;
     
        /**
         * Constructors
         */
        public DrawPanel() {
     
        }
     
        public DrawPanel(ImageIcon image) {
        	BufferedImage newImg = new BufferedImage(image.getIconWidth(), image.getIconHeight(),BufferedImage.TYPE_INT_RGB);
        	Graphics g = newImg.createGraphics();
            g.drawImage(image.getImage(),0,0,null);
     
        	historic.add(newImg);
        	g.dispose();
        }
     
        /**
         * Set the new image to the panel and add it in the historic
         */
        public void setImage(BufferedImage image) {
     
        	BufferedImage newImg = new BufferedImage(image.getWidth(), image.getHeight(),BufferedImage.TYPE_INT_RGB);
        	Graphics g = newImg.createGraphics();
            g.drawImage(image,0,0,null);
            currentIndexImage++;
            historic.add(newImg);
            g.dispose();
     
        	//repaint();
        }
     
        /**
         * @return the image used for painting the background of this panel
         */
        public BufferedImage getImage() {
        	//System.out.println("Set Image Get = " + currentIndexImage);
        	return historic.get(currentIndexImage);
        }
     
        public BufferedImage getPrevImage() {
        	currentIndexImage--;
    		return getImage();
    	}
     
        public BufferedImage getNextImage() {
        	currentIndexImage++;
    		return getImage();
    	}
     
        public boolean isFirstImage() {
    		return currentIndexImage == 0;
    	}
     
        public boolean isLastImage() {
    		return currentIndexImage == historic.size()-1;
    	}
     
        public void setPreferredSize(Dimension pref) {
        	preferredSize = pref;
        	super .setPreferredSize(pref);
        }
     
        public Dimension getPreferredSize() {
        	BufferedImage img = historic.get(currentIndexImage);
        	if (preferredSize == null && img != null) {
        		//it has not been explicitly set, so return the width/height of the image 
        		int width = img.getWidth(null);
        		int height = img.getHeight(null);
        		if (width == - 1|| height == -1) {
        			return super .getPreferredSize();
        		}
        		return new Dimension(width, height);
        	} else {
        		return super .getPreferredSize();
        	}
        }
     
        /**
         * Overriden to paint the image on the panel
         */
        protected void paintComponent(Graphics g) {
        	super.paintComponent(g); 
        	Graphics2D g2 = (Graphics2D) g;
        	BufferedImage img = historic.get(currentIndexImage);
        	if (img != null) {
        		final int imgWidth = img.getWidth(null);
        		final int imgHeight = img.getHeight(null);
        		if (imgWidth == -1 || imgHeight == -1) {
        			//image hasn't completed loading, return
        			return;
        		}
     
        		Insets insets = getInsets();
        		final int pw = getWidth() - insets.left - insets.right;
        		final int ph = getHeight() - insets.top - insets.bottom;
     
     
     
     
        		Rectangle clipRect = g2.getClipBounds();
        		int imageX = (pw - imgWidth) /2  + insets.left;
        		int imageY = (ph - imgHeight) /2  + insets.top;
        		Rectangle r = SwingUtilities.computeIntersection(
        				imageX, imageY, imgWidth, imgHeight, clipRect);
     
        		if (r.x ==0  && r.y ==0 && (r.width ==0  || r.height ==0 )) {
        			return;
        		}	
        		//	I have my new clipping rectangle "r" in clipRect space.
        		//It is therefore the new clipRect.
        		clipRect = r;
        		//	since I have the intersection, all I need to do is adjust the
        		//x & y values for the image
        		int txClipX = clipRect.x - imageX;
        		int txClipY = clipRect.y - imageY;
        		int txClipW = clipRect.width;
        		int txClipH = clipRect.height;
       			g2.drawImage(img, clipRect.x, clipRect.y, clipRect.x
      					+ clipRect.width, clipRect.y + clipRect.height,
       					txClipX, txClipY, txClipX + txClipW, txClipY
       					+ txClipH, null);
        	}
        }
    }
    ImageEditor.java
    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
     
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JInternalFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
     
    public class ImageEditor extends JFrame implements  ActionListener ,MouseListener, MouseMotionListener
    {
     /* Current mouse coordinates */
     private int mousex                = 0;
     private int mousey                = 0;
     
     /* Previous mouse coordinates */
     private int prevx                 = 0;
     private int prevy                 = 0;
     
     
     /* Initial state flags for operation */
     private boolean initialPen        = true;
     
     
     /* Primitive status & color variables */
     
     private Color  redColor          = new Color(255,0,0);
     
     
     /* Assorted status values for different variables */
     private JTextField mouseStatusBar  = new JTextField(10);
     
     
     /* Labels for operation and color fields */
     private JLabel cursorLabel         = new JLabel("   Cursor:");
     private JButton undoButton         = new JButton("Undo");
     private JButton redoButton         = new JButton("Redo");
     
     
     /* Sub panels of the main frame */
     private JPanel statusPanel         = new JPanel(new GridLayout(1,4,0,0));
     private DrawPanel drawPanel        = new DrawPanel(new ImageIcon("C:/smile.PNG"));
     
     private JPanel statusAndColorPanel = new JPanel(new GridLayout(2,1));
     
     private BufferedImage bi;
     
     public void init()
     {
    	setTitle("ImagEditor v.1");
        setLayout(new BorderLayout());
        setSize(350, 350);
     
     
        /* Add label and cursor text field */
        statusPanel.add(cursorLabel);
        statusPanel.add(mouseStatusBar);
        statusPanel.add(undoButton);
        statusPanel.add(redoButton);
     
        // Add undo and redo buttons to actionListener
        undoButton.addActionListener(this);
        redoButton.addActionListener(this);
     
     
        /* Set not editable */
        mouseStatusBar.setEditable(false);
     
        statusAndColorPanel.add(statusPanel);
     
        // InteralFrame containing the panel displaying the image
        JInternalFrame maFrame = new JInternalFrame();
        maFrame.setVisible(true);
        maFrame.setLayout(new BorderLayout());
        JPanel centerPanel = new JPanel();
        centerPanel.add(maFrame);
    	drawPanel.addMouseListener(this);
    	drawPanel.addMouseMotionListener(this);
    	maFrame.add(drawPanel,BorderLayout.CENTER);
    	maFrame.pack();
     
     
    	 // Place panel in the frame
        add(statusAndColorPanel, "North");
        add(centerPanel, "Center");
     
        this.setVisible(true);
        pack();
     }
     
     
    /**
     * Draw a line from the previous mouse coordinates 
     * to the current mouse coordinates
     */
     private void dessinePen(Graphics g) {
    	 g.drawLine(prevx,prevy,mousex,mousey);
    	 g.dispose();
    	 drawPanel.repaint();
     }
     
     /*
       Method will emulate a pen style graphic.
       by drawing a line from the previous mouse corrdinates
       to the current mouse coordinates.
     
       Note: In initial attempt the previous mouse coordinates
             are set to the current mouse coordinates so as
             not to begin the pen graphic from an unwanted
             arbitrary point.
     */
     public void penOperation(MouseEvent e)
     {
    	 bi = drawPanel.getImage();
    	 Graphics g = bi.createGraphics();
    	 g.setColor(redColor);
     
    	 // In initial state setup default values for mouse coordinates
    	 if (initialPen)
    	 {
    		 setGraphicalDefaults(e);
    		 initialPen = false;
    		 dessinePen(g);
    	 }
     
    	 // Make sure that the mouse has actually moved from its previous position.
    	 if (mouseHasMoved(e))
    	 {
    		 // set mouse coordinates to current mouse position
    		 mousex = e.getX();
    		 mousey = e.getY();
     
    		 dessinePen(g);
     
    		 // Set the current mouse coordinates to previous mouse coordinates for next time
    		 prevx = mousex;
    		 prevy = mousey;
    	 }
     }
     
     /**
      * Implement actionPerformed method
      */
     public void actionPerformed(ActionEvent e) {
    		if (e.getSource() == undoButton) {
    			undoOperation();
    		}
    		if (e.getSource() == redoButton) {
    			redoOperation();
    		}
     }
     
     public void undoOperation() 
     {
    	if (!drawPanel.isFirstImage()) {
    		BufferedImage bi  = drawPanel.getPrevImage();  
    		Graphics g = drawPanel.getGraphics();
    		g.drawImage(bi,0,0,null);
    		g.dispose();
    		drawPanel.repaint();
    	}
    	else {
    		System.out.println("Première Image");
    	}
    	//drawPanel.testAll();
     }
     
     public void redoOperation() 
     {
    	 if (!drawPanel.isLastImage()) {
    		 BufferedImage bi  = drawPanel.getNextImage();    
    		 Graphics g = drawPanel.getGraphics();
    		 g.drawImage(bi,0,0,null);
    		 g.dispose();
    		 drawPanel.repaint();
    	 }
    	 else {
    		 System.out.println("Dernière Image");
    	 }
     
     }
     /*
       Method determines weather the mouse has moved
       from its last recorded position.
       If mouse has deviated from previous position,
       the value returned will be true, otherwise
       the value that is returned will be false.
     */
     public boolean mouseHasMoved(MouseEvent e)
     {
        return (mousex != e.getX() || mousey != e.getY());
     }
     
     
     /*
       Method sets all the drawing varibles to the default
       state which is the current position of the mouse cursor
       Also the height and width varibles are zeroed off.
     */
     public void setGraphicalDefaults(MouseEvent e)
     {
        mousex   = e.getX();
        mousey   = e.getY();
        prevx    = e.getX();
        prevy    = e.getY();
     }
     
     
     /*
       Method will be activated when mouse is being dragged.
       depending on what operation is the opstatus, the switch
       statement will call the relevent operation
     */
     public void mouseDragged(MouseEvent e)
     {
        updateMouseCoordinates(e);
     
        penOperation(e);
     }
     
     
     /*
        Method will be activated when mouse has been release from pressed \
        mode. At this stage the method will call the finalization routines
        for the current operation.
     */
     public void mouseReleased(MouseEvent e)
     {
        /* Update current mouse coordinates to screen */
        updateMouseCoordinates(e);
     
        releasedPen();                 
     }
     
     
     /*
        Method will be activated when mouse enters the applet area.
        This method will then update the current mouse x and coordinates
        on the screen.
     */
     public void mouseEntered(MouseEvent e)
     {
        updateMouseCoordinates(e);
     }
     
     
     /*
       Method is invoked when mouse has been released
       and current operation is Pen
     */
     public void releasedPen()
     {
        initialPen = true;
        bi  = drawPanel.getImage();
     
        drawPanel.setImage(bi);
        //drawPanel.repaint();
     }
     
     
     
     /*
       Method displays the mouse coordinates x and y values
       and updates the mouse status bar with the new values.
     */
     public void updateMouseCoordinates(MouseEvent e)
     {
        String xCoor ="";
        String yCoor ="";
     
        if (e.getX() < 0) xCoor = "0";
        else
        {
           xCoor = String.valueOf(e.getX());
        }
     
        if (e.getY() < 0) xCoor = "0";
        else
        {
           yCoor = String.valueOf(e.getY());
        }
     
        mouseStatusBar.setText("x:"+xCoor+"   y:"+yCoor);
     
     }
     
     
     /*
       Method updates mouse coordinates if mouse has been clicked
     */
     public void mouseClicked(MouseEvent e)
     {
        updateMouseCoordinates(e);
    }
     
     
     /*
       Method updates mouse coordinates if mouse has exited the frame
     */
     public void mouseExited(MouseEvent e)
     {
        updateMouseCoordinates(e);
     }
     
     
     /*
       Method updates mouse coordinates if mouse has moved
     */
     public void mouseMoved(MouseEvent e)
     {
        updateMouseCoordinates(e);
     }
     
     
     /*
       Method updates mouse coordinates if mouse has been pressed
     */
     public void mousePressed(MouseEvent e)
     {
        updateMouseCoordinates(e);
     }
     
     
    }
    Main.java
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    public class Main {
     
    	/**
             * @param args
             */
    	public static void main(String[] args) {
    		ImageEditor sc = new ImageEditor();
    		sc.setDefaultCloseOperation(ImageEditor.EXIT_ON_CLOSE);
    		sc.init(); 
    	}
    }
    L'image de Test

  2. #2
    Modérateur
    Avatar de dinobogan
    Homme Profil pro
    ingénieur
    Inscrit en
    Juin 2007
    Messages
    4 073
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France

    Informations professionnelles :
    Activité : ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 4 073
    Par défaut
    Tu ne penses pas assez objet. Du coup ton code est compliqué. Ton DrawPanel doit gérer tout seul les undo/redo, et aucune classe extérieure ne devrait avoir le droit de dessiner directement sur son graphics.
    Voici une solution possible qui fonctionne :
    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
     
    import javax.swing.ImageIcon;
    import javax.swing.JPanel;
     
    public class DrawPanel extends JPanel
    {
    	// Historic of the images
    	private ImageUndoRedo imageUndoRedo = null;
     
    	private Dimension preferredSize;
     
    	/**
             * Constructors
             */
    	public DrawPanel( int width, int height )
    	{
    		imageUndoRedo = new ImageUndoRedo();
    		imageUndoRedo.image = new BufferedImage( width, height, BufferedImage.TYPE_INT_RGB );
    	}
     
    	public DrawPanel( ImageIcon image )
    	{
    		this( image.getIconWidth(), image.getIconHeight() );
    		Graphics g = getImage().getGraphics();
    		g.drawImage( image.getImage(), 0, 0, this );
    		g.dispose();
    	}
     
    	public void newImage()
    	{
    		int width = getWidth();
    		int height = getHeight();
    		if( getImage() != null )
    		{
    			width = getImage().getWidth();
    			height = getImage().getHeight();
    		}
     
    		BufferedImage newImg = new BufferedImage( width, height, BufferedImage.TYPE_INT_RGB );
    		if( getImage() != null )
    		{
    			Graphics g = newImg.getGraphics();
    			g.drawImage( getImage(), 0, 0, this );
    			g.dispose();
    		}
     
    		if( imageUndoRedo.next != null )
    		{
    			imageUndoRedo.next.previous = null;
    		}
     
    		imageUndoRedo.next = new ImageUndoRedo();
    		imageUndoRedo.next.previous = imageUndoRedo;
    		imageUndoRedo = imageUndoRedo.next;
    		imageUndoRedo.image = newImg;
    		repaint();
    	}
     
    	/**
             * @return the image used for painting the background of this panel
             */
    	private BufferedImage getImage()
    	{
    		return imageUndoRedo.image;
    	}
     
    	public void toPrevImage()
    	{
    		if( ! isFirstImage() )
    		{
    			imageUndoRedo = imageUndoRedo.previous;
    			repaint();
    		}
    	}
     
    	public void toNextImage()
    	{
    		if( ! isLastImage() )
    		{
    			imageUndoRedo = imageUndoRedo.next;
    			repaint();
    		}
    	}
     
    	public boolean isFirstImage()
    	{
    		return ! imageUndoRedo.hasPrevious();
    	}
     
    	public boolean isLastImage()
    	{
    		return ! imageUndoRedo.hasNext();
    	}
     
    	public void setPreferredSize( Dimension pref )
    	{
    		preferredSize = pref;
    		super.setPreferredSize( pref );
    	}
     
    	public Dimension getPreferredSize()
    	{
    		BufferedImage img = getImage();
    		if( preferredSize == null && img != null )
    		{
    			// it has not been explicitly set, so return the width/height of the
    			// image
    			int width = img.getWidth( null );
    			int height = img.getHeight( null );
    			if( width == -1 || height == -1 )
    			{
    				return super.getPreferredSize();
    			}
    			return new Dimension( width, height );
    		}
    		else
    		{
    			return super.getPreferredSize();
    		}
    	}
     
    	/**
             * Overriden to paint the image on the panel
             */
    	protected void paintComponent( Graphics g )
    	{
    		super.paintComponent( g );
    		g.drawImage( getImage(), 0, 0, this );
    	}
     
    	public void drawLine( int x1, int y1, int x2, int y2 )
    	{
    		Graphics g = getImage().getGraphics();
    		g.setColor( Color.RED );
    		g.drawLine( x1, y1, x2, y2 );
    		g.dispose();
    		repaint();
    	}
    }
     
    class ImageUndoRedo
    {
    	public ImageUndoRedo previous = null;
    	public ImageUndoRedo next = null;
    	public BufferedImage image;
     
    	public ImageUndoRedo(){}
     
    	public boolean hasPrevious() { return previous != null; }
    	public boolean hasNext() { return next != null; }
    }
    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
     
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JInternalFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
     
    public class ImageEditor extends JFrame implements ActionListener, MouseListener, MouseMotionListener
    {
    	/* Previous mouse coordinates */
    	private int prevx = 0;
    	private int prevy = 0;
     
    	/* Assorted status values for different variables */
    	private JTextField mouseStatusBar = new JTextField( 10 );
     
    	/* Labels for operation and color fields */
    	private JLabel cursorLabel = new JLabel( "   Cursor:" );
    	private JButton undoButton = new JButton( "Undo" );
    	private JButton redoButton = new JButton( "Redo" );
     
    	/* Sub panels of the main frame */
    	private JPanel statusPanel = new JPanel( new GridLayout( 1, 4, 0, 0 ) );
    	private DrawPanel drawPanel = new DrawPanel( 320, 200 );
     
    	private JPanel statusAndColorPanel = new JPanel( new GridLayout( 2, 1 ) );
     
    	public void init()
    	{
    		setTitle( "ImagEditor v.1" );
    		setLayout( new BorderLayout() );
    		setSize( 350, 350 );
     
    		/* Add label and cursor text field */
    		statusPanel.add( cursorLabel );
    		statusPanel.add( mouseStatusBar );
    		statusPanel.add( undoButton );
    		statusPanel.add( redoButton );
     
    		// Add undo and redo buttons to actionListener
    		undoButton.addActionListener( this );
    		redoButton.addActionListener( this );
     
    		/* Set not editable */
    		mouseStatusBar.setEditable( false );
     
    		statusAndColorPanel.add( statusPanel );
     
    		// InteralFrame containing the panel displaying the image
    		JInternalFrame maFrame = new JInternalFrame();
    		maFrame.setVisible( true );
    		maFrame.setLayout( new BorderLayout() );
    		JPanel centerPanel = new JPanel();
    		centerPanel.add( maFrame );
    		drawPanel.addMouseListener( this );
    		drawPanel.addMouseMotionListener( this );
    		maFrame.add( drawPanel, BorderLayout.CENTER );
    		maFrame.pack();
     
    		// Place panel in the frame
    		add( statusAndColorPanel, "North" );
    		add( centerPanel, "Center" );
     
    		this.setVisible( true );
    		pack();
    	}
     
    	/**
             * Implement actionPerformed method
             */
    	public void actionPerformed( ActionEvent e )
    	{
    		if( e.getSource() == undoButton )
    		{
    			drawPanel.toPrevImage();
    		}
    		if( e.getSource() == redoButton )
    		{
    			drawPanel.toNextImage();
    		}
     
    		undoButton.setEnabled( ! drawPanel.isFirstImage() );
    		redoButton.setEnabled( ! drawPanel.isLastImage() );
    	}
     
    	public void mousePressed( MouseEvent e ) 
    	{ 
    		drawPanel.newImage();
    		prevx = e.getX();
    		prevy = e.getY();
    	}
     
    	/*
    	 * Method will be activated when mouse is being dragged. depending on what
    	 * operation is the opstatus, the switch statement will call the relevent
    	 * operation
    	 */
    	public void mouseDragged( MouseEvent e )
    	{
    		updateMouseCoordinates( e );
    		drawPanel.drawLine( prevx, prevy, e.getX(), e.getY() );
    		prevx = e.getX();
    		prevy = e.getY();
    	}
     
    	/*
    	 * Method displays the mouse coordinates x and y values and updates the
    	 * mouse status bar with the new values.
    	 */
    	public void updateMouseCoordinates( MouseEvent e )
    	{
    		mouseStatusBar.setText( "x:" + e.getX() + "   y:" + e.getY() );
    	}
     
    	public void mouseMoved( MouseEvent e ) { updateMouseCoordinates( e ); }
     
    	public void mouseReleased( MouseEvent e ) {}
    	public void mouseEntered( MouseEvent e ) {}
    	public void mouseClicked( MouseEvent e ) {}
    	public void mouseExited( MouseEvent e ) {}
    }
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java
    Que la force de la puissance soit avec le courage de ta sagesse.

  3. #3
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    je rajoute que ceci est mauvais:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    		Graphics g = drawPanel.getGraphics();
    		g.drawImage(bi,0,0,null);
    		g.dispose();
    on n'accède pas au Graphics directement comme ça. Tu devrais juste notifier ton drawpanel de repasser à l'état précédent et ensuite appeler repaint. Ne jamais tenter de dessiner à un autre moment que quand on te le demande (via des appels à paintXXXX faits par swing

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    47
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2006
    Messages : 47
    Par défaut
    Merci bcp pour vos réponses...

    En effet, mon code est plus compliqué que la solution que tu proposes...

    Dinobogan, je peux te demander comment tu dessinerais un rectangle sur le Panel ? (car DrawPanel implémente juste l'action de dessin à main levée)

    Merci de ton aide...

  5. #5
    Modérateur
    Avatar de dinobogan
    Homme Profil pro
    ingénieur
    Inscrit en
    Juin 2007
    Messages
    4 073
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France

    Informations professionnelles :
    Activité : ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 4 073
    Par défaut
    Citation Envoyé par fcjunic Voir le message
    Merci bcp pour vos réponses...

    En effet, mon code est plus compliqué que la solution que tu proposes...

    Dinobogan, je peux te demander comment tu dessinerais un rectangle sur le Panel ? (car DrawPanel implémente juste l'action de dessin à main levée)

    Merci de ton aide...
    Pour dessiner le rectangle, il suffit de dessiner la diagonale. Dans ton interface, tu ajoutes un bouton pour choisir la forme à dessiner. Il faut ajouter une fonction à DrawPanel pour dessiner un rectangle.
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java
    Que la force de la puissance soit avec le courage de ta sagesse.

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    47
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2006
    Messages : 47
    Par défaut
    Merci pour tes réponses, je suis mtnt bien avancé dans mon editeur...

    Il me reste uniquement un petit détail que je n'arrive pas à corriger...Quand je dessine une ellipse, la méthode "drawOval(x,y,width,height)" de la classe Graphics dessine également le point de référence (représentant le coin de référence du rectangle englobant l'ellipse)

    Pour que ce soit plus clair, voici le screenshot du probleme...



    DrawPanel
    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
     
    import javax.swing.ImageIcon;
    import javax.swing.JPanel;
     
    public class DrawPanel extends JPanel
    {
    	// Historic of the images
    	private ImageUndoRedo imageUndoRedo = null;
     
    	private Dimension preferredSize;
     
    	/**
             * Constructors
             */
    	public DrawPanel( int width, int height )
    	{
    		imageUndoRedo = new ImageUndoRedo();
    		imageUndoRedo.image = new BufferedImage( width, height, BufferedImage.TYPE_INT_RGB );
    	}
     
    	public DrawPanel( ImageIcon image )
    	{
    		this( image.getIconWidth(), image.getIconHeight() );
    		Graphics g = getImage().getGraphics();
    		g.drawImage( image.getImage(), 0, 0, this );
    		g.dispose();
    	}
     
    	public void newImage()
    	{
    		int width = getWidth();
    		int height = getHeight();
    		if( getImage() != null )
    		{
    			width = getImage().getWidth();
    			height = getImage().getHeight();
    		}
     
    		BufferedImage newImg = new BufferedImage( width, height, BufferedImage.TYPE_INT_RGB );
    		if( getImage() != null )
    		{
    			Graphics g = newImg.getGraphics();
    			g.drawImage( getImage(), 0, 0, this );
    			g.dispose();
    		}
     
    		if( imageUndoRedo.next != null )
    		{
    			imageUndoRedo.next.previous = null;
    		}
     
    		imageUndoRedo.next = new ImageUndoRedo();
    		imageUndoRedo.next.previous = imageUndoRedo;
    		imageUndoRedo = imageUndoRedo.next;
    		imageUndoRedo.image = newImg;
    		repaint();
    	}
     
    	/**
             * @return the image used for painting the background of this panel
             */
    	private BufferedImage getImage()
    	{
    		return imageUndoRedo.image;
    	}
     
    	public void toPrevImage()
    	{
    		if( ! isFirstImage() )
    		{
    			imageUndoRedo = imageUndoRedo.previous;
    			repaint();
    		}
    	}
     
    	public void toNextImage()
    	{
    		if( ! isLastImage() )
    		{
    			imageUndoRedo = imageUndoRedo.next;
    			repaint();
    		}
    	}
     
    	public boolean isFirstImage()
    	{
    		return ! imageUndoRedo.hasPrevious();
    	}
     
    	public boolean isLastImage()
    	{
    		return ! imageUndoRedo.hasNext();
    	}
     
    	public void setPreferredSize( Dimension pref )
    	{
    		preferredSize = pref;
    		super.setPreferredSize( pref );
    	}
     
    	public Dimension getPreferredSize()
    	{
    		BufferedImage img = getImage();
    		if( preferredSize == null && img != null )
    		{
    			// it has not been explicitly set, so return the width/height of the
    			// image
    			int width = img.getWidth( null );
    			int height = img.getHeight( null );
    			if( width == -1 || height == -1 )
    			{
    				return super.getPreferredSize();
    			}
    			return new Dimension( width, height );
    		}
    		else
    		{
    			return super.getPreferredSize();
    		}
    	}
     
    	/**
             * Overriden to paint the image on the panel
             */
    	protected void paintComponent( Graphics g )
    	{
    		super.paintComponent( g );
    		g.drawImage( getImage(), 0, 0, this );
    	}
     
    	/*
    	 * Draw Ellipse
    	 */
    	public void drawOval(int drawX, int drawY, int orWidth, int orHeight) {
     
    		Graphics2D g = (Graphics2D)getImage().getGraphics();
    		g.setXORMode(this.getBackground());
    		g.setColor(Color.BLUE);
    		g.drawOval(drawX, drawY, orWidth, orHeight);
    		g.dispose();
     
    		repaint();	
    	}
    }
     
    class ImageUndoRedo
    {
    	public ImageUndoRedo previous = null;
    	public ImageUndoRedo next = null;
    	public BufferedImage image;
     
    	public ImageUndoRedo(){}
     
    	public boolean hasPrevious() { return previous != null; }
    	public boolean hasNext() { return next != null; }
    }
    ImageEditor
    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
     
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JInternalFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
     
    public class ImageEditor extends JFrame implements ActionListener, MouseListener, MouseMotionListener
    {
    	/* Previous mouse coordinates */
    	private int prevx = 0;
    	private int prevy = 0;
     
    	/* Assorted status values for different variables */
    	private JTextField mouseStatusBar = new JTextField( 10 );
     
    	// Current mouse coordinates 
    	private int mousex = 0;
    	private int mousey = 0;
     
    	// Main Mouse X and Y coordinate variables 
    	private int  Orx          = 0;
    	private int  Ory          = 0;
    	private int  OrWidth      = 0;
    	private int  OrHeight     = 0;
    	private int  drawX        = 0;
    	private int  drawY        = 0;
     
    	/* Labels for operation and color fields */
    	private JLabel cursorLabel = new JLabel( "   Cursor:" );
    	private JButton undoButton = new JButton( "Undo" );
    	private JButton redoButton = new JButton( "Redo" );
     
    	/* Sub panels of the main frame */
    	private JPanel statusPanel = new JPanel( new GridLayout( 1, 4, 0, 0 ) );
    	private DrawPanel drawPanel = new DrawPanel( 320, 200 );
     
    	private JPanel statusAndColorPanel = new JPanel( new GridLayout( 2, 1 ) );
     
    	public void init()
    	{
    		setTitle( "ImagEditor v.1" );
    		setLayout( new BorderLayout() );
    		setSize( 350, 350 );
     
    		/* Add label and cursor text field */
    		statusPanel.add( cursorLabel );
    		statusPanel.add( mouseStatusBar );
    		statusPanel.add( undoButton );
    		statusPanel.add( redoButton );
     
    		// Add undo and redo buttons to actionListener
    		undoButton.addActionListener( this );
    		redoButton.addActionListener( this );
     
    		/* Set not editable */
    		mouseStatusBar.setEditable( false );
     
    		statusAndColorPanel.add( statusPanel );
     
    		// InteralFrame containing the panel displaying the image
    		JInternalFrame maFrame = new JInternalFrame();
    		maFrame.setVisible( true );
    		maFrame.setLayout( new BorderLayout() );
    		JPanel centerPanel = new JPanel();
    		centerPanel.add( maFrame );
    		drawPanel.addMouseListener( this );
    		drawPanel.addMouseMotionListener( this );
    		maFrame.add( drawPanel, BorderLayout.CENTER );
    		maFrame.pack();
     
    		// Place panel in the frame
    		add( statusAndColorPanel, "North" );
    		add( centerPanel, "Center" );
     
    		this.setVisible( true );
    		pack();
    	}
     
    	/**
             * Implement actionPerformed method
             */
    	public void actionPerformed( ActionEvent e )
    	{
    		if( e.getSource() == undoButton )
    		{
    			drawPanel.toPrevImage();
    		}
    		if( e.getSource() == redoButton )
    		{
    			drawPanel.toNextImage();
    		}
     
    		undoButton.setEnabled( ! drawPanel.isFirstImage() );
    		redoButton.setEnabled( ! drawPanel.isLastImage() );
    	}
     
    	/*
    	 * When mouse is pressed create a new image
    	 * (and initialize mouse coordinates values)
    	 */
    	public void mousePressed( MouseEvent e ) 
    	{ 
    		drawPanel.newImage();
    		setGraphicalDefaults(e);
    	}
     
    	/*
    	 * Method sets all the drawing varibles to the default
    	 * state which is the current position of the mouse cursor
    	 * Also the height and width varibles are zeroed off.
    	 */
    	public void setGraphicalDefaults(MouseEvent e)
    	{
    		mousex   = e.getX();
    		mousey   = e.getY();
    		prevx    = e.getX();
    		prevy    = e.getY();
    		Orx      = e.getX();
    		Ory      = e.getY();
    		drawX    = e.getX();
    		drawY    = e.getY();
    		OrWidth  = 0;
    		OrHeight = 0;
    	}
     
    	/*
    	 * Method will be activated when mouse is being dragged. depending on what
    	 * operation is the opstatus, the switch statement will call the relevent
    	 * operation
    	 */
    	public void mouseDragged( MouseEvent e )
    	{
    		updateMouseCoordinates( e );
     
    		drawPanel.drawOval(drawX,drawY,OrWidth,OrHeight);
     
    		/* Update new mouse coordinates */
    		mousex = e.getX();
    		mousey = e.getY();
     
    		/* Check new mouse coordinates for negative errors */
    		setActualBoundary();
     
    		/* Draw rectangle shadow */
    		drawPanel.drawOval(drawX,drawY,OrWidth,OrHeight);
    	}
     
    	public void setActualBoundary()
    	{
     
    		/*
             If the any of the current mouse coordinates
             are smaller than the origin coordinates, meaning
             if drag occured in a negative manner, where either
             the x-shift occured from right and/or y-shift occured
             from bottom to top.
    		 */
    		if (mousex < Orx || mousey < Ory)
    		{
     
    			/*
                if the current mouse x coordinate is smaller
                than the origin x coordinate,
                equate the drawX to be the difference between
                the current width and the origin x coordinate.
    			 */
    			if (mousex < Orx)
    			{
    				OrWidth = Orx - mousex;
    				drawX   = Orx - OrWidth;
    			}
     
    			else
    			{
    				drawX    = Orx;
    				OrWidth  = mousex - Orx;
     
    			}
     
    			/*
                if the current mouse y coordinate is smaller
                than the origin y coordinate,
                equate the drawY to be the difference between
                the current height and the origin y coordinate.
    			 */
    			if (mousey < Ory)
    			{
    				OrHeight = Ory - mousey;
    				drawY    = Ory - OrHeight;
    			}
     
    			else
    			{
    				drawY    = Ory;
    				OrHeight = mousey - Ory;
    			}
     
    		}
     
    		/*
             Else if drag was done in a positive manner meaning
             x-shift occured from left to right and or y-shift occured
             from top to bottom
    		 */
    		else
    		{
    			drawX    = Orx;
    			drawY    = Ory;
    			OrWidth  = mousex - Orx;
    			OrHeight = mousey - Ory;
    		}
     
    	}
     
    	/*
    	 * Method displays the mouse coordinates x and y values and updates the
    	 * mouse status bar with the new values.
    	 */
    	public void updateMouseCoordinates( MouseEvent e )
    	{
    		mouseStatusBar.setText( "x:" + e.getX() + "   y:" + e.getY() );
    	}
     
    	public void mouseMoved( MouseEvent e ) { updateMouseCoordinates( e ); }
     
    	public void mouseReleased( MouseEvent e ) {}
    	public void mouseEntered( MouseEvent e ) {}
    	public void mouseClicked( MouseEvent e ) {}
    	public void mouseExited( MouseEvent e ) {}
    }
    Main
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    public class Main {
     
    	/**
             * @param args
             */
    	public static void main(String[] args) {
    		ImageEditor sc = new ImageEditor();
    		sc.setDefaultCloseOperation(ImageEditor.EXIT_ON_CLOSE);
    		sc.init(); 
    	}
    }
    Une idée du pourquoi ?

    Merci...

  7. #7
    Modérateur
    Avatar de dinobogan
    Homme Profil pro
    ingénieur
    Inscrit en
    Juin 2007
    Messages
    4 073
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France

    Informations professionnelles :
    Activité : ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 4 073
    Par défaut
    Je pense que tu as dessiné un ovale de largeur et hauteur zéro.
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java
    Que la force de la puissance soit avec le courage de ta sagesse.

  8. #8
    Membre averti
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    47
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2006
    Messages : 47
    Par défaut
    Merci bcp pour ton aide...

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème avec l'insertion dans une ArrayList
    Par LoveIinfo dans le forum Collection et Stream
    Réponses: 7
    Dernier message: 08/06/2011, 22h29
  2. Charger des images dans une ArrayList
    Par user2000 dans le forum Android
    Réponses: 0
    Dernier message: 10/12/2010, 10h26
  3. Des problèmes pour ajouter valeur dans une ArrayList
    Par Fused dans le forum Collection et Stream
    Réponses: 4
    Dernier message: 07/11/2008, 16h28
  4. Réponses: 1
    Dernier message: 13/12/2006, 21h31
  5. Problème d'insertion d'image dans une fenêtre.
    Par Antigonos Ier Gonatas dans le forum Tkinter
    Réponses: 2
    Dernier message: 26/08/2006, 12h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo