Re: Best Approach for putting words on a JPanel (with special requirements) [2nd attempted post]



PaulSchrum wrote:
...
I want each word to be discrete entity, and I want to have absolute
control over the font, size, etc of the text, along with absolute
control of the position of the text on the JPanel.

Where are you going to put it? Describe it in words. Some examples...

One after the other, then wrapping down the panel.. (FlowLayout)
In a vertical column of equally sized areas down the panel (GridLayout)
Scrolling from left to right across the panel each in turn
(custom layout 'ScrollLayout')
Wherever the user 'drops' it (custom layout - must account
for components overlapping 'DropLayout/AbsoluteLayout')

The thing is, to make a custom layout, you need to
translate those words to Java code, and as soon as you
can express it in words, the Java code for the custom
layout becomes (relatively) easy.

My first attempt was just to .drawString the words on the JPanel and I
got that to work fine.

If you know where to 'drawString()' you can position the label at the same poistion, though it usually makes more sense to encapsulate the logic behind the drawString co-ordinates in your custom layout.

Having said that, here is a very simple example of a ScrollLayout,
though note that one of the true GUI gurus was advising me
that it could use further improvement - read the thread
for further details..

HTH

--
Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew
.