Re: how do you put images on a screen?
Andrew Thompson wrote:
... Lew's pointer to the 2D part of the
tutorial is another way to do it (whereas the way I
place the image in the example, is 'crude and simple').
I came into Swing programming ass backwards, and I don't have anywhere near
Andrew's expertise, particularly in the GUI aspects of Swing. A couple of
years back I did a project to print /n/-up images, much as a printer runs off
a batch of business cards. (/n/-up printing is a grid layout of the same
item, /n/ to a row, as many rows as fit on a page.) This required extensive
use of Java 2D and affine transforms. Yummy.
People gripe about Swing as a GUI framework, but really it's quite potent. I
used to program GUIs in Motif and Open Look; there's a distinct similarity of
outlook among these frameworks.
Anyway, that experience has me more attuned to the 2D library than some folks
might be.
FWIW, I implemented the project as a grid of JPanels with a BufferedImage
drawn into each of them, scaled to fit. Details escape me after this time,
but I think I also played some fun games with laying out text over top of the
image within each JPanel.
Then the print library came into play. More fun. I was surprised to find
that Java lets a body do some magic with a printer.
The result was a WYSIWYG /n/-up print-layout tool.
After some learning curve, including even buying a book, it really wasn't so
hard to do it. Familiarity with the API was the key, as with everything Java.
It did turn out pretty hard to put together what I wanted to know about the
Java printing libraries. For one thing, there are at least two. Not entirely
incompatible with each other. For another no one source really said much
about it. There would be a little bit here, another take on it there, all
over the place. It took me some effort to synthesize information from the
disparate sources in that area.
--
Lew