arrays - Image display within GridBagLayout Java -
My image is passed from one server to my program and is saved as a string I use that string as an image I want to convert, and then display a picture inside a label inside a GridBagLayout
when I execute the code below, I get a blank frame, there is no exception during execution. When I look at the image object in the debug from ToolKit
, it says that the height and width are -1 (but there is "Imagetta" within source = byteArrayImageSource
[5144] ]). Any ideas?
Added note: Image is stored in the program as string because the data is sorted into C # and being deserialized within Java. This process does not explicitly like byte []
in the deserialize process, so I save it as a string and I use getBytes
when I use the image Want to use
imageToDisplay = Toolkit.getDefaultToolkit (). CreateImage (myString.getBytes ()); Image icon logo icon = new image icon (imageddomypeplay); JLab logoLabel = new JLabel (logo icon); MainPanel.add (Logolabel, New Gridbag Consultants (0, 0, 1, 1, 1.0, 1.0, Gridbag Consultants. EAST, Gridbag Console, Horizontal, New Inset (2, 2, 2, 2), 0, 0)); MainFrame.add (mainpanel, new gridbag consultants (0, 0, 1, 1, 1.0, 1.0, gridbag consultants.cr, gridbag consultancy.both, new instances (2, 2, 2, 2), 0, 0));
First you should know that the problem is the image or layout suggest the Emmires and the flow out Keep a panel (possibly self) with If it still is not visible, then this image may be there is a reason why the input is converted to string? The default charset may not be able to handle the conversion (which, bytes -> string -> bytes can not give you the same initial byte).
Comments
Post a Comment