0

I have two Swing GUI.I successfully transferred some information between each other.

My problem is that,i try to show byte array in JLabel. I wrote code, but I can't show my image, because byte array is large. Here is source

jPanel1.setLayout(new FlowLayout());
ImageIcon icon = new ImageIcon(byteArray);
JLabel label = new JLabel();
label.setIcon(icon);
jPanel1.add(label);

I tested another small byte array (I inserted it in google) and it's working. Is it a possible to resize byte array before put in in another GUI? How i can solve my problem? Thanks

Max
  • 915
  • 10
  • 28
BekaKK
  • 2,173
  • 6
  • 42
  • 80

1 Answers1

0

This question has a working answer here.

Basically, you have to convert your byte[] array to an ImageIcon object first and then add it to your label.

Cheers

xoX Zeus Xox
  • 195
  • 1
  • 14
  • Thanks your atthention. I also found this question and tested it.As you can see there is a static byte array,when i tested it ,it's worked,but not working when i use my byte array @xoX Zeus Xox – BekaKK Aug 03 '17 at 07:21
  • Could you please provide more of your code that is relevant to this question, e.g. your byte array declaration and initialization? – xoX Zeus Xox Aug 03 '17 at 07:24
  • @Baggio, `when i tested it ,it's worked,` - so you have proven the concept of using a byte array works. `but not working when i use my byte array` - then your byte array doesn't contain valid data. – camickr Aug 03 '17 at 14:43