You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Scott Lanham <li...@sael.com.au> on 2011/03/18 06:42:25 UTC

PushButton Text Wrap

Hello,

Sorry if I have asked this in the past. I can't seem to find any old posts 
about it and my memory is not so good.

Is it possible to get the text in a PushButton to wrap rather than clip when 
then text is longer than the button width?

Thanks,

Scott.

Re: PushButton Text Wrap

Posted by Chris Bartlett <cb...@gmail.com>.
No problem.  Sometimes it takes me 10 mins to find threads that I know are
there.

On 22 March 2011 08:11, Scott Lanham <li...@sael.com.au> wrote:

> Thanks Chris,
>
> I did what I thought was a thorough search of the archives. Wasn't thorough
> enough.
>
> On Mon, 21 Mar 2011 11:14:12 pm Chris Bartlett wrote:
> > Scott,
> >
> > See this thread.
> >
> http://apache-pivot-users.399431.n3.nabble.com/include-2-0-tp2260648p226064
> > 8.html
> >
> > On 21 March 2011 08:37, Scott Lanham <li...@sael.com.au> wrote:
> > > On another topic, I can't seem to bind to objects that have been nested
> > > using
> > > bxml:include. I used to use WTKXSerializer#get() and use a "." in
> between
> > > names to deliniate the name spaces. I tried using
> > > BXMLSerializer.getNamespace().get using the same name structure and it
> > > didn't
> > > work. Has this all changed for 2.0?
> > >
> > > Cheers,
> > >
> > > Scott.
>

Re: PushButton Text Wrap

Posted by Scott Lanham <li...@sael.com.au>.
Thanks Chris,

I did what I thought was a thorough search of the archives. Wasn't thorough 
enough.

On Mon, 21 Mar 2011 11:14:12 pm Chris Bartlett wrote:
> Scott,
> 
> See this thread.
> http://apache-pivot-users.399431.n3.nabble.com/include-2-0-tp2260648p226064
> 8.html
> 
> On 21 March 2011 08:37, Scott Lanham <li...@sael.com.au> wrote:
> > On another topic, I can't seem to bind to objects that have been nested
> > using
> > bxml:include. I used to use WTKXSerializer#get() and use a "." in between
> > names to deliniate the name spaces. I tried using
> > BXMLSerializer.getNamespace().get using the same name structure and it
> > didn't
> > work. Has this all changed for 2.0?
> > 
> > Cheers,
> > 
> > Scott.

Re: PushButton Text Wrap

Posted by Scott Lanham <li...@sael.com.au>.
import org.apache.pivot.wtk.HorizontalAlignment;
import org.apache.pivot.wtk.Orientation;
import org.apache.pivot.wtk.content.ButtonDataRenderer;

public class ButtonDataRenderer_wrappedText extends ButtonDataRenderer
{
    public ButtonDataRenderer_wrappedText()
    {
        setOrientation( Orientation.VERTICAL );
        getStyles().put( "fill", true );
        label.getStyles().put( "horizontalAlignment", HorizontalAlignment.CENTER );
        label.getStyles().put("wrapText", true);        
    }
}

On Wed, 30 Mar 2011 04:40:53 am Roger L. Whitcomb wrote:
> Hi Scott,
> 	Could you publish what your code looks like that is now working?
> We're having a similar issue with Checkbox and I thought I followed all
> the instructions here but it is not working still...  Thanks.
> 
> Roger Whitcomb | Architect, Engineering | Roger.Whitcomb@ingres.com |
> Ingres | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 |
> USA  +1 650-587-5596 | fax: +1 650-587-5550
> 

RE: PushButton Text Wrap

Posted by "Roger L. Whitcomb" <Ro...@ingres.com>.
Hi Scott,
	Could you publish what your code looks like that is now working?
We're having a similar issue with Checkbox and I thought I followed all
the instructions here but it is not working still...  Thanks.

Roger Whitcomb | Architect, Engineering | Roger.Whitcomb@ingres.com |
Ingres | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 |
USA  +1 650-587-5596 | fax: +1 650-587-5550

-----Original Message-----
From: Scott Lanham [mailto:lists@sael.com.au] 
Sent: Sunday, March 27, 2011 6:30 PM
To: user@pivot.apache.org
Subject: Re: PushButton Text Wrap

Thanks Greg. It is all good :-)

On Sun, 27 Mar 2011 10:45:56 pm Greg Brown wrote:
> Try setting the horizontalAlignment style on the renderer's label.
> 
> On Mar 26, 2011, at 7:08 PM, Scott Lanham wrote:
> > That worked :-)
> > 
> > Now I just have to figure out how to get the text to align
horizontally
> > to the centre.
> > 
> > On Sat, 26 Mar 2011 08:14:12 am Greg Brown wrote:
> >> Oh, right. It is a horizontal box pane. If you make it vertical and
set
> >> fill to true, it will wrap.
> >> 
> >> On Mar 25, 2011, at 5:55 PM, Scott Lanham wrote:
> >>> Setting "fill" to true just pushes the text to the top of the
button
> >>> but doesn't wrap it.
> >>> 
> >>> On Fri, 25 Mar 2011 10:09:55 pm Greg Brown wrote:
> >>>> Seems like it might be related to the other button renderer
discussion
> >>>> that has been going on. Try setting the "fill" style to true on
the
> >>>> button data renderer itself in addition to setting "wrapText" to
true
> >>>> on the label.
> >>>> 
> >>>> On Mar 25, 2011, at 12:31 AM, Scott Lanham wrote:
> >>>>> On Tue, 22 Mar 2011 11:00:54 pm Greg Brown wrote:
> >>>>>>> That didn't appear to work. I created this class:
> >>>>>>> 
> >>>>>>> public class ButtonDataRenderer_wrappedText extends
> >>>>>>> ButtonDataRenderer {
> >>>>>>> 
> >>>>>>> public ButtonDataRenderer_wrappedText(){
> >>>>>>> 
> >>>>>>>     label.getStyles().put("wrapText", true);
> >>>>>>> 
> >>>>>>> }
> >>>>>>> 
> >>>>>>> }
> >>>>>>> 
> >>>>>>> And set the DataRenderer:
> >>>>>>> 
> >>>>>>> PushButton#setDataRenderer( new
ButtonDataRenderer_wrappedText())
> >>>>>> 
> >>>>>> Is the button in a container that will apply a width constraint
to
> >>>>>> it? Alternatively, have you given the button a preferred width
to
> >>>>>> wrap to?
> >>>>> 
> >>>>> The button is contained in a Grid Pane. The only style I set on
the
> >>>>> button is the font. A screen shot is attached. The buttons are
on the
> >>>>> right hand side.
> >>>>> 
> >>>>> Thanks,
> >>>>> 
> >>>>> Scott.
> >>>>> <ct3_orders.png>

Re: PushButton Text Wrap

Posted by Scott Lanham <li...@sael.com.au>.
Thanks Greg. It is all good :-)

On Sun, 27 Mar 2011 10:45:56 pm Greg Brown wrote:
> Try setting the horizontalAlignment style on the renderer's label.
> 
> On Mar 26, 2011, at 7:08 PM, Scott Lanham wrote:
> > That worked :-)
> > 
> > Now I just have to figure out how to get the text to align horizontally
> > to the centre.
> > 
> > On Sat, 26 Mar 2011 08:14:12 am Greg Brown wrote:
> >> Oh, right. It is a horizontal box pane. If you make it vertical and set
> >> fill to true, it will wrap.
> >> 
> >> On Mar 25, 2011, at 5:55 PM, Scott Lanham wrote:
> >>> Setting "fill" to true just pushes the text to the top of the button
> >>> but doesn't wrap it.
> >>> 
> >>> On Fri, 25 Mar 2011 10:09:55 pm Greg Brown wrote:
> >>>> Seems like it might be related to the other button renderer discussion
> >>>> that has been going on. Try setting the "fill" style to true on the
> >>>> button data renderer itself in addition to setting "wrapText" to true
> >>>> on the label.
> >>>> 
> >>>> On Mar 25, 2011, at 12:31 AM, Scott Lanham wrote:
> >>>>> On Tue, 22 Mar 2011 11:00:54 pm Greg Brown wrote:
> >>>>>>> That didn't appear to work. I created this class:
> >>>>>>> 
> >>>>>>> public class ButtonDataRenderer_wrappedText extends
> >>>>>>> ButtonDataRenderer {
> >>>>>>> 
> >>>>>>> public ButtonDataRenderer_wrappedText(){
> >>>>>>> 
> >>>>>>>     label.getStyles().put("wrapText", true);
> >>>>>>> 
> >>>>>>> }
> >>>>>>> 
> >>>>>>> }
> >>>>>>> 
> >>>>>>> And set the DataRenderer:
> >>>>>>> 
> >>>>>>> PushButton#setDataRenderer( new ButtonDataRenderer_wrappedText())
> >>>>>> 
> >>>>>> Is the button in a container that will apply a width constraint to
> >>>>>> it? Alternatively, have you given the button a preferred width to
> >>>>>> wrap to?
> >>>>> 
> >>>>> The button is contained in a Grid Pane. The only style I set on the
> >>>>> button is the font. A screen shot is attached. The buttons are on the
> >>>>> right hand side.
> >>>>> 
> >>>>> Thanks,
> >>>>> 
> >>>>> Scott.
> >>>>> <ct3_orders.png>

Re: PushButton Text Wrap

Posted by Greg Brown <gk...@verizon.net>.
Try setting the horizontalAlignment style on the renderer's label.

On Mar 26, 2011, at 7:08 PM, Scott Lanham wrote:

> That worked :-)
> 
> Now I just have to figure out how to get the text to align horizontally to the 
> centre.
> 
> On Sat, 26 Mar 2011 08:14:12 am Greg Brown wrote:
>> Oh, right. It is a horizontal box pane. If you make it vertical and set
>> fill to true, it will wrap.
>> 
>> On Mar 25, 2011, at 5:55 PM, Scott Lanham wrote:
>>> Setting "fill" to true just pushes the text to the top of the button but
>>> doesn't wrap it.
>>> 
>>> On Fri, 25 Mar 2011 10:09:55 pm Greg Brown wrote:
>>>> Seems like it might be related to the other button renderer discussion
>>>> that has been going on. Try setting the "fill" style to true on the
>>>> button data renderer itself in addition to setting "wrapText" to true
>>>> on the label.
>>>> 
>>>> On Mar 25, 2011, at 12:31 AM, Scott Lanham wrote:
>>>>> On Tue, 22 Mar 2011 11:00:54 pm Greg Brown wrote:
>>>>>>> That didn't appear to work. I created this class:
>>>>>>> 
>>>>>>> public class ButtonDataRenderer_wrappedText extends
>>>>>>> ButtonDataRenderer {
>>>>>>> 
>>>>>>> public ButtonDataRenderer_wrappedText(){
>>>>>>> 
>>>>>>>     label.getStyles().put("wrapText", true);
>>>>>>> 
>>>>>>> }
>>>>>>> 
>>>>>>> }
>>>>>>> 
>>>>>>> And set the DataRenderer:
>>>>>>> 
>>>>>>> PushButton#setDataRenderer( new ButtonDataRenderer_wrappedText())
>>>>>> 
>>>>>> Is the button in a container that will apply a width constraint to it?
>>>>>> Alternatively, have you given the button a preferred width to wrap to?
>>>>> 
>>>>> The button is contained in a Grid Pane. The only style I set on the
>>>>> button is the font. A screen shot is attached. The buttons are on the
>>>>> right hand side.
>>>>> 
>>>>> Thanks,
>>>>> 
>>>>> Scott.
>>>>> <ct3_orders.png>


Re: PushButton Text Wrap

Posted by Scott Lanham <li...@sael.com.au>.
That worked :-)

Now I just have to figure out how to get the text to align horizontally to the 
centre.

On Sat, 26 Mar 2011 08:14:12 am Greg Brown wrote:
> Oh, right. It is a horizontal box pane. If you make it vertical and set
> fill to true, it will wrap.
> 
> On Mar 25, 2011, at 5:55 PM, Scott Lanham wrote:
> > Setting "fill" to true just pushes the text to the top of the button but
> > doesn't wrap it.
> > 
> > On Fri, 25 Mar 2011 10:09:55 pm Greg Brown wrote:
> >> Seems like it might be related to the other button renderer discussion
> >> that has been going on. Try setting the "fill" style to true on the
> >> button data renderer itself in addition to setting "wrapText" to true
> >> on the label.
> >> 
> >> On Mar 25, 2011, at 12:31 AM, Scott Lanham wrote:
> >>> On Tue, 22 Mar 2011 11:00:54 pm Greg Brown wrote:
> >>>>> That didn't appear to work. I created this class:
> >>>>> 
> >>>>> public class ButtonDataRenderer_wrappedText extends
> >>>>> ButtonDataRenderer {
> >>>>> 
> >>>>>  public ButtonDataRenderer_wrappedText(){
> >>>>>  
> >>>>>      label.getStyles().put("wrapText", true);
> >>>>>  
> >>>>>  }
> >>>>> 
> >>>>> }
> >>>>> 
> >>>>> And set the DataRenderer:
> >>>>> 
> >>>>> PushButton#setDataRenderer( new ButtonDataRenderer_wrappedText())
> >>>> 
> >>>> Is the button in a container that will apply a width constraint to it?
> >>>> Alternatively, have you given the button a preferred width to wrap to?
> >>> 
> >>> The button is contained in a Grid Pane. The only style I set on the
> >>> button is the font. A screen shot is attached. The buttons are on the
> >>> right hand side.
> >>> 
> >>> Thanks,
> >>> 
> >>> Scott.
> >>> <ct3_orders.png>

Re: PushButton Text Wrap

Posted by Greg Brown <gk...@verizon.net>.
Oh, right. It is a horizontal box pane. If you make it vertical and set fill to true, it will wrap.

On Mar 25, 2011, at 5:55 PM, Scott Lanham wrote:

> Setting "fill" to true just pushes the text to the top of the button but 
> doesn't wrap it.
> 
> On Fri, 25 Mar 2011 10:09:55 pm Greg Brown wrote:
>> Seems like it might be related to the other button renderer discussion that
>> has been going on. Try setting the "fill" style to true on the button data
>> renderer itself in addition to setting "wrapText" to true on the label.
>> 
>> On Mar 25, 2011, at 12:31 AM, Scott Lanham wrote:
>>> On Tue, 22 Mar 2011 11:00:54 pm Greg Brown wrote:
>>>>> That didn't appear to work. I created this class:
>>>>> 
>>>>> public class ButtonDataRenderer_wrappedText extends ButtonDataRenderer
>>>>> {
>>>>> 
>>>>>  public ButtonDataRenderer_wrappedText(){
>>>>> 
>>>>>      label.getStyles().put("wrapText", true);
>>>>> 
>>>>>  }
>>>>> 
>>>>> }
>>>>> 
>>>>> And set the DataRenderer:
>>>>> 
>>>>> PushButton#setDataRenderer( new ButtonDataRenderer_wrappedText())
>>>> 
>>>> Is the button in a container that will apply a width constraint to it?
>>>> Alternatively, have you given the button a preferred width to wrap to?
>>> 
>>> The button is contained in a Grid Pane. The only style I set on the
>>> button is the font. A screen shot is attached. The buttons are on the
>>> right hand side.
>>> 
>>> Thanks,
>>> 
>>> Scott.
>>> <ct3_orders.png>


Re: PushButton Text Wrap

Posted by Scott Lanham <li...@sael.com.au>.
Setting "fill" to true just pushes the text to the top of the button but 
doesn't wrap it.

On Fri, 25 Mar 2011 10:09:55 pm Greg Brown wrote:
> Seems like it might be related to the other button renderer discussion that
> has been going on. Try setting the "fill" style to true on the button data
> renderer itself in addition to setting "wrapText" to true on the label.
> 
> On Mar 25, 2011, at 12:31 AM, Scott Lanham wrote:
> > On Tue, 22 Mar 2011 11:00:54 pm Greg Brown wrote:
> >>> That didn't appear to work. I created this class:
> >>> 
> >>> public class ButtonDataRenderer_wrappedText extends ButtonDataRenderer
> >>> {
> >>> 
> >>>   public ButtonDataRenderer_wrappedText(){
> >>>   
> >>>       label.getStyles().put("wrapText", true);
> >>>   
> >>>   }
> >>> 
> >>> }
> >>> 
> >>> And set the DataRenderer:
> >>> 
> >>> PushButton#setDataRenderer( new ButtonDataRenderer_wrappedText())
> >> 
> >> Is the button in a container that will apply a width constraint to it?
> >> Alternatively, have you given the button a preferred width to wrap to?
> > 
> > The button is contained in a Grid Pane. The only style I set on the
> > button is the font. A screen shot is attached. The buttons are on the
> > right hand side.
> > 
> > Thanks,
> > 
> > Scott.
> > <ct3_orders.png>

Re: PushButton Text Wrap

Posted by Scott Lanham <li...@sael.com.au>.
I have been doing some experimentation.

If I put a label in cell of a grid pane it wraps. If I put a box pane in the 
cell and put the label in that, it no longer wraps.

On Fri, 25 Mar 2011 02:31:43 pm Scott Lanham wrote:
> On Tue, 22 Mar 2011 11:00:54 pm Greg Brown wrote:
> > > That didn't appear to work. I created this class:
> > > 
> > > public class ButtonDataRenderer_wrappedText extends ButtonDataRenderer
> > > {
> > > 
> > >    public ButtonDataRenderer_wrappedText(){
> > >    
> > >        label.getStyles().put("wrapText", true);
> > >    
> > >    }
> > > 
> > > }
> > > 
> > > And set the DataRenderer:
> > > 
> > > PushButton#setDataRenderer( new ButtonDataRenderer_wrappedText())
> > 
> > Is the button in a container that will apply a width constraint to it?
> > Alternatively, have you given the button a preferred width to wrap to?
> 
> The button is contained in a Grid Pane. The only style I set on the button
> is the font. A screen shot is attached. The buttons are on the right hand
> side.
> 
> Thanks,
> 
> Scott.

Re: PushButton Text Wrap

Posted by Greg Brown <gk...@verizon.net>.
Seems like it might be related to the other button renderer discussion that has been going on. Try setting the "fill" style to true on the button data renderer itself in addition to setting "wrapText" to true on the label.

On Mar 25, 2011, at 12:31 AM, Scott Lanham wrote:

> On Tue, 22 Mar 2011 11:00:54 pm Greg Brown wrote:
>>> That didn't appear to work. I created this class:
>>> 
>>> public class ButtonDataRenderer_wrappedText extends ButtonDataRenderer {
>>> 
>>>   public ButtonDataRenderer_wrappedText(){
>>> 
>>>       label.getStyles().put("wrapText", true);
>>> 
>>>   }
>>> 
>>> }
>>> 
>>> And set the DataRenderer:
>>> 
>>> PushButton#setDataRenderer( new ButtonDataRenderer_wrappedText())
>> 
>> Is the button in a container that will apply a width constraint to it?
>> Alternatively, have you given the button a preferred width to wrap to?
>> 
> 
> The button is contained in a Grid Pane. The only style I set on the button is 
> the font. A screen shot is attached. The buttons are on the right hand side.
> 
> Thanks,
> 
> Scott. 
> <ct3_orders.png>


Re: PushButton Text Wrap

Posted by Scott Lanham <li...@sael.com.au>.
On Tue, 22 Mar 2011 11:00:54 pm Greg Brown wrote:
> > That didn't appear to work. I created this class:
> > 
> > public class ButtonDataRenderer_wrappedText extends ButtonDataRenderer {
> > 
> >    public ButtonDataRenderer_wrappedText(){
> >    
> >        label.getStyles().put("wrapText", true);
> >    
> >    }
> > 
> > }
> > 
> > And set the DataRenderer:
> > 
> > PushButton#setDataRenderer( new ButtonDataRenderer_wrappedText())
> 
> Is the button in a container that will apply a width constraint to it?
> Alternatively, have you given the button a preferred width to wrap to?
> 

The button is contained in a Grid Pane. The only style I set on the button is 
the font. A screen shot is attached. The buttons are on the right hand side.

Thanks,

Scott. 

Re: PushButton Text Wrap

Posted by Greg Brown <gk...@verizon.net>.
> That didn't appear to work. I created this class:
> 
> public class ButtonDataRenderer_wrappedText extends ButtonDataRenderer {
>    public ButtonDataRenderer_wrappedText(){
>        label.getStyles().put("wrapText", true);
>    }
> }
> 
> And set the DataRenderer:
> 
> PushButton#setDataRenderer( new ButtonDataRenderer_wrappedText())

Is the button in a container that will apply a width constraint to it? Alternatively, have you given the button a preferred width to wrap to?

> On another topic, I can't seem to bind to objects that have been nested using 
> bxml:include. I used to use WTKXSerializer#get() and use a "." in between 
> names to deliniate the name spaces. I tried using 
> BXMLSerializer.getNamespace().get using the same name structure and it didn't 
> work. Has this all changed for 2.0?

Yes, this did change in 2.0. Include variables are now effectively "private" to the include. This helps promote encapsulation and reinforces the notion of includes as independent modules.

To get the previous behavior, you can add a getter method to your include's root element class that returns the referenced value.

G


Re: PushButton Text Wrap

Posted by Chris Bartlett <cb...@gmail.com>.
Scott,

See this thread.
http://apache-pivot-users.399431.n3.nabble.com/include-2-0-tp2260648p2260648.html

On 21 March 2011 08:37, Scott Lanham <li...@sael.com.au> wrote:

> On another topic, I can't seem to bind to objects that have been nested
> using
> bxml:include. I used to use WTKXSerializer#get() and use a "." in between
> names to deliniate the name spaces. I tried using
> BXMLSerializer.getNamespace().get using the same name structure and it
> didn't
> work. Has this all changed for 2.0?
>
> Cheers,
>
> Scott.
>

Re: PushButton Text Wrap

Posted by Scott Lanham <li...@sael.com.au>.
Hi Greg,

That didn't appear to work. I created this class:

public class ButtonDataRenderer_wrappedText extends ButtonDataRenderer {
    public ButtonDataRenderer_wrappedText(){
        label.getStyles().put("wrapText", true);
    }
}

And set the DataRenderer:

PushButton#setDataRenderer( new ButtonDataRenderer_wrappedText())

On another topic, I can't seem to bind to objects that have been nested using 
bxml:include. I used to use WTKXSerializer#get() and use a "." in between 
names to deliniate the name spaces. I tried using 
BXMLSerializer.getNamespace().get using the same name structure and it didn't 
work. Has this all changed for 2.0?

Cheers,

Scott.

On Fri, 18 Mar 2011 10:20:39 pm Greg Brown wrote:
> Yes. I thought that ButtonDataRenderer wrapped text by default, but
> apparently it doesn't. Easiest thing would be to create a custom subclass
> of ButtonDataRenderer and call label.getStyles().put("wrapText", true) in
> the constructor. Then set this as the renderer for your button.
> 
> On Mar 18, 2011, at 1:42 AM, Scott Lanham wrote:
> > Hello,
> > 
> > Sorry if I have asked this in the past. I can't seem to find any old
> > posts about it and my memory is not so good.
> > 
> > Is it possible to get the text in a PushButton to wrap rather than clip
> > when then text is longer than the button width?
> > 
> > Thanks,
> > 
> > Scott.

Re: PushButton Text Wrap

Posted by Greg Brown <gk...@verizon.net>.
Yes. I thought that ButtonDataRenderer wrapped text by default, but apparently it doesn't. Easiest thing would be to create a custom subclass of ButtonDataRenderer and call label.getStyles().put("wrapText", true) in the constructor. Then set this as the renderer for your button.

On Mar 18, 2011, at 1:42 AM, Scott Lanham wrote:

> Hello,
> 
> Sorry if I have asked this in the past. I can't seem to find any old posts 
> about it and my memory is not so good.
> 
> Is it possible to get the text in a PushButton to wrap rather than clip when 
> then text is longer than the button width?
> 
> Thanks,
> 
> Scott.