This discussion is archived
7 Replies Latest reply: Jun 12, 2009 1:54 AM by 843851 RSS

How can i get Overflow text in HStaticText Component

843851 Newbie
Currently Being Moderated
Hi!
i am trying to develop a component which will scroll the text content passed into that just like a TextArea. i am using a HStaticText button to display the content and DVBTextLayoutManager for wrapping the extra text which is not fit into same line. i have added TextOverflowListener in that. How can i handle the text content for scrolling. Any help or idea.
Thanks in advance
  • 1. Re: How can i get Overflow text in HStaticText Component
    843851 Newbie
    Currently Being Moderated
    For scrolling I made a "widget" composed of a HContainer and a HText element with all the text in. The HContainer is the size of the scroll you want and the HText moves inside it so you'll only see the text through the HContainer like a window.
  • 2. Re: How can i get Overflow text in HStaticText Component
    843851 Newbie
    Currently Being Moderated
    Hi!
    thanks for your replay. I have solve the problem by using the same way and its working.
  • 3. Re: How can i get Overflow text in HStaticText Component
    843851 Newbie
    Currently Being Moderated
    but how can i know the necesary heigth of the HText

    THX
  • 4. Re: How can i get Overflow text in HStaticText Component
    843851 Newbie
    Currently Being Moderated
    You can use the vertical overflow listener. Each time an overflow event arrives, add 5 (for example) to the height of the text container. This will be repeated until there's no overflow.
  • 5. Re: How can i get Overflow text in HStaticText Component
    843851 Newbie
    Currently Being Moderated
    Can you please post the sample code for the scroll...??

    Regards
    RMN
  • 6. Re: How can i get Overflow text in HStaticText Component
    843851 Newbie
    Currently Being Moderated
    Hi, I make a sample of the scroll widget. I expect that will be help you.
    My apologize for my english.
    import java.awt.Dimension;
    import java.awt.Point;
    
    import org.dvb.ui.DVBTextLayoutManager;
    import org.havi.ui.HContainer;
    import org.havi.ui.HText;
    
    public class ScrollableArea extends HContainer{
         
         //HContainer container;
         HText text;
         DVBTextLayoutManager layout;
         
         public ScrollableArea(){
              //container=new HContainer();
              super();
              text=new HText("asd asd as da sd asd as d asd as d asd as" +
                        "adfasf asf asf asf asfas fasf af asf" +
                        "asf asf asf asf asf asf asfa fasfa sf asfa sf" +
                        "qwqwr qwerq rq rqw rq wr qw rq wr qwr qwr qwrqwr " +
                        "qrqwr qwmr qwr rw qw rqwr  qwrqwrwqrqr qw r qwr" +
                        " qwrq wrqwrq r qw rq wr qwr qw rq wr qwr q wrq wrq" +
                        "l lhj lhjl h jl hjl  jl hj l hjl jh l hjl jhl" +
                        "hjl hjl h l hj lh l jh lhj lh jlhj lhj lh l hl h jl" +
                        "zc zc z xc zc zxc zxc zxc  zxc zx czxczxczx  czx " +
                        " zxcz c z czxc zxc zx c zxc zxc zxc zx" +
                        "zxc zc z czx czxczxc zx vz vbvcb cv ncn n b "+
                        "asd asd as da sd asd as d asd as d asd as" +
                        "adfasf asf asf asf asfas fasf af asf" +
                        "asf asf asf asf asf asf asfa fasfa sf asfa sf" +
                        "qwqwr qwerq rq rqw rq wr qw rq wr qwr qwr qwrqwr " +
                        "qrqwr qwmr qwr rw qw rqwr  qwrqwrwqrqr qw r qwr" +
                        " qwrq wrqwrq r qw rq wr qwr qw rq wr qwr q wrq wrq" +
                        "l lhj lhjl h jl hjl  jl hj l hjl jh l hjl jhl" +
                        "hjl hjl h l hj lh l jh lhj lh jlhj lhj lh l hl h jl" +
                        "zc zc z xc zc zxc zxc zxc  zxc zx czxczxczx  czx " +
                        " zxcz c z czxc zxc zx c zxc zxc zxc zx" +
                        "zxc zc z czx czxczxc zx vz vbvcb cv ncn n b ");
              layout=new DVBTextLayoutManager();
              text.setTextLayoutManager(layout);
              text.setLocation(0, 0);
              text.setSize(300, 500);
              layout.setTextWrapping(true);
              this.add(text);
         }
         public void up(){
              Point p=text.getLocation();
              Dimension d=this.getSize();
              if(p.y>=d.height)
                   System.out.println("No se hace mas scroll");
              else
                   text.setLocation(0,p.y+10);     
         }
         
         public void down(){
              Point p=text.getLocation();
              Dimension d=text.getSize();
              if(p.y<= -d.height)
                   System.out.println("No se hace mas scroll");
              else
                   text.setLocation(0,p.y-10);     
         }
         
    
    }
  • 7. Re: How can i get Overflow text in HStaticText Component
    843851 Newbie
    Currently Being Moderated
    Thanks for the code....