My image is passed into my program from a server and saved as a string. I want to convert that string into an image, and then in turn display that image within a label inside of a GridBagLayout. When I execute the below code, I get a blank frame. No exceptions during execution. When I look at the image object from the ToolKit in debug, it does say height and width are -1 (but the "imagedata" within the "source = ByteArrayImageSource" has byte[5144]). Any ideas?
Added Note: Image is stored in program as a String because the data is serialized in C# and is being deserialized within Java. This process apparently does not like byte[] in the deserialize process so I save it as a string and use getBytes when I want to use the image.
imageToDisplay = Toolkit.getDefaultToolkit().createImage(myString.getBytes());
ImageIcon logoIcon = new ImageIcon(imageToDisplay);
JLabel logolabel = new JLabel(logoIcon);
mainPanel.add(logolabel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL,
new Insets(2, 2, 2, 2), 0, 0));
mainFrame.add(mainPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(2, 2, 2, 2), 0, 0));