I am using a GridPrint to format some data, but I've run into an issue where the cell contents can be either an Image or Text or both. Ideally, I'd like to be able to populate a particular cell with some text and (if one is available) an image next to it (in the same cell). I'd prefer it in the same cell, and not in the next column, because the text may or may not have an accompanying image. So the extra column for the image might not be necessary. Any thoughts?
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using a GridPrint to format some data, but I've run into an issue where the cell contents can be either an Image or Text or both. Ideally, I'd like to be able to populate a particular cell with some text and (if one is available) an image next to it (in the same cell). I'd prefer it in the same cell, and not in the next column, because the text may or may not have an accompanying image. So the extra column for the image might not be necessary. Any thoughts?
Thanks.
If the cell contains both text and an image, you could combine them into one Print before adding that print to the GridPrint:
GridPrint cell = new GridPrint("d,d");
cell.add(new TextPrint(text));
cell.add(new ImagePrint(image));
grid.add(cell);
You could also use StyledTextPrint which permits any Print to be inserted alongside text, and aligns non-text elements on the text's baseline.
Matthew