1 2 Previous Next 27 Replies Latest reply on May 31, 2007 3:41 AM by 807600

    converting ImageIcon to string...and back again

      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();

      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
        1 2 Previous Next