Hi Roger, On Thu, Jul 18, 2013 at 9:31 PM, Roger L. Whitcomb <roger.whitc...@actian.com> wrote: > > Hi Ajay, > Label doesn't have near the capability of a TextArea (or > TextPane) as far as manipulation of its parts. It is meant to be a > single piece of text, all with the same attributes. And, in fact, if > you want to change the color of a single word, then you're going to have > to use TextPane, and set up some text spans that have different > attributes. Or you could use a series of Labels, each with one piece of > the text, and line them up with a BoxPane or FlowPane so it appears they > are one. That way you could change the attributes of one Label at a > time. Caveat: I haven't actually tried this, but I'm pretty sure you > could play with the margins and such on the enclosing container to make > this work pretty well. But TextPane is the component that is actually > meant for this sort of thing, but it is a little bit more difficult to > setup the document structure. But, you can take a look at the > TextPaneDemo.java file for examples on working with a TextPane, and > applying styles to various pieces of text within it. You could make it > read-only (with "setEditable(false)") so that it simulates a Label in > appearance. > > HTH, > ~Roger Whitcomb >
Great, I'll look into that. I've got another (related?) question. Let's say I have a label defined inside a box pane and a list of strings, all of which are wise sayings. Let me have 2 buttons. > > Eg: Entered text is: > > > > The quick brown fox jumps over the lazy dog. > > Let the label be empty at first. Then if I click 1st button I need the label to display the first saying. I click the button again, I get the second saying and so on. For the 2nd button if I click it, the label gets added to the box pane at first, then shows the saying, and then carries out repaint operation. How to do both of these? -- Thanks and regards, Ajay Bhat