1 2 Previous Next 27 Replies Latest reply: May 30, 2007 8:58 PM by EJP RSS

    converting ImageIcon to string...and back again

    807600
      I am creating a 3x3 puzzle game with 9 buttons and images on each button, I want to pass the image from one button to another - someone told me this was done by converting the icon to a string and then passing it on. I've done this but icon then doesn't like strings and I'm not sure how to convert it back into something it does like.

      Here's the code:
      public void actionPerformed(ActionEvent event) {
                if (event.getSource() == btnBotC8) {
                     if(btnBotR9.getIcon().toString()== pic9) {
                          strBtn = btnBotC8.getIcon().toString();
                          btnBotC8.setIcon(btnBotR9.getIcon());
                          btnBotR9.setIcon(pic9);
                     }     
                }     

      pic 9 is a blank image, ie the one I want the others to move into.....however I am not sure if this is what
      I should be referring to in this case!

      Any help would be sooo much appreciated
      Thanks in advance
      Claire
        1 2 Previous Next