How to automatically scroll text in JScrollPane

Hi there
I have a very simple question...
How to automatically scroll text in JScrollPane?
Text in the TextArea is constantly getting updated... but the scroll bars dont' move as the text changes. Instead I ahve to scroll and see the changes everytime. How can I make the viewport or the scrollpane to show the latest content?
Thanks in advance.
Dexter

This question is asked daily (it seems) on the forum. Hopefully the TextAreaScroll class will explain whats going on:
**  Short answer is to use the following after the append:
**  textArea.setCaretPosition(textArea.getDocument().getLength()
**  However, if you really want to know what is going on, then I have
**  I have observed the following behaviour in JDK1.4.2
**  JTextArea will scroll automatically when text is appended, if:
**  a) the caret is at the end of the text area, and
**  b) the append is done in the event thread
**  Note: Initializing a text area at creation time by any of the following
**  aproaches will cause the caret to be positioned at the start and therefore
**  scrolling will not happen automatically:
**  a) JTextArea textArea = new JTextArea("Initial text", ...);
**  b) textArea.setText("Initial text");
**  c) textArea.read(someFile, null);
**  The append method can be forced to execute in the Event thread by using
**  SwingUtilities.invokeLater();
**  Alternatively you can force a scroll by repositioning the caret.
import java.awt.*;
import java.awt.event.*;
import java.util.Date;
import javax.swing.*;
import javax.swing.text.*;
public class TextAreaScroll
     public static void main(String[] args)
          final JTextArea textAreaWest = new JTextArea(10, 25);
          JScrollPane scrollPaneWest = new JScrollPane( textAreaWest );
          final JTextArea textAreaEast = new JTextArea(10, 25);
          JScrollPane scrollPaneEast = new JScrollPane( textAreaEast );
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          frame.getContentPane().add(scrollPaneWest, BorderLayout.WEST);
          frame.getContentPane().add(scrollPaneEast, BorderLayout.EAST);
          frame.pack();
          frame.setVisible(true);
          //  The West text area will be updated by a Timer. Timer code is
          //  executed in the Event thread so it will scroll correctly.
          new Timer(1000, new ActionListener()
               public void actionPerformed(ActionEvent e)
                    if (textAreaWest.getDocument().getLength() == 0)
                         textAreaWest.append("West will scroll correctly");
                    textAreaWest.append( "\n" + new Date().toString());
          }).start();
          //  The East text area is not updated in the Event thread.
          //  It will not scroll correctly.
          while (true)
               try
                    if (textAreaEast.getDocument().getLength() == 0)
                         textAreaEast.append("East will not scroll correctly");
                    textAreaEast.append( "\n" + new Date().toString() );
                    //  Using this method causes the text area to scroll because
                    //  this method will invoke SwingUtilities.invokeLater(...)
                    textAreaEast.setCaretPosition( textAreaEast.getDocument().getLength() );
                    //  Using SwingUtilities.invokeLater causes the code to execute
                    //  on the Event thread
                    //  (comment all the above lines before testing)
                    SwingUtilities.invokeLater( new Runnable()
                         public void run()
                              textAreaEast.append( "\n" + new Date().toString() );
                    Thread.sleep(1000);
               catch (InterruptedException ie) {}
}

Similar Messages

  • How to Automatically copy text from PO Line to Fi Doc

    Hello Friends,
    can any one help me on this to resolve the issue.
    How I can Automatically copy text from PO Line to Fi Doc and replicate text from fi doc controlling reports .
    t-code- me23n
    the Header text has to copy in to FI document, accounting doc, profit center doc.
    FI When  GR posted  (WE ) PO  header text (Tab)  -à must be to copied to GR Finance document header  and
    PO  item  Text must be Copied to à Finance Document  Lint  item text
    Rgards!
    skr

    Hello,
    I got the BADI - AC_DOCUMENT and under IF_EX_AC_DOCUMENT~CHANGE_AFTER_CHECK i have to use my code. can any one send me some sample code plz.
    here i have to pass the po number and get the bktxt value.

  • Cant get automatic scrolling text pane to work from other classes

    Hi guys, I've been creating a program that utilises JInternalFrames, one of which frames is an "event log" which is simply a Document I append text to, problem is I'm getting some strange logic errors. It works fine if it's just left alone and adds text from its internal timer method, but as soon (sometimes on 3rd or 4th call) of it's static method called 'append' it starts spewing out error message - mainly ""AWT-EventQueue-0" java.lang.NullPointerException", and stops working.
    Here is my internal frame (a MyJDesktopPane component), with its internal appendText that works fine.
    import java.awt.event.*;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import javax.swing.*;
    public class EventLog extends JInternalFrame {
        public EventLog() {
            super("",
                      false,      //resizable
                      false,      //closable
                      false,      //maximizable
                      true);     //iconifiable
            atp = new ELInternal();
            this.getContentPane().add(new JScrollPane(atp));
            this.setSize(200, 200);
            this.setVisible(true);
            // Add some text every second
            Timer t = new Timer(1000, new ActionListener() {
              public void actionPerformed(ActionEvent evt) {
                String timeString = fmt.format(new Date());
                atp.appendText(timeString + "\n");
              SimpleDateFormat fmt = new SimpleDateFormat("HH:mm:ss");
            t.start();
        public static void append(String in)
             try {
                       atp.appendText(in + "\n");
             } catch ( Exception e  ){}
        static ELInternal atp;
    }Here is the internal panes content:
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class ELInternal extends JTextPane {
      public ELInternal() {
        super();
      public ELInternal(StyledDocument doc) {
        super(doc);
      // Appends text to the document and ensure that it is visible
      public  void appendText(String text) {
        try {
          Document doc = getDocument();
          // Move the insertion point to the end
          setCaretPosition(doc.getLength());
          // Insert the text
          replaceSelection(text);
          // Convert the new end location
          // to view co-ordinates
          Rectangle r = modelToView(doc.getLength());
          // Finally, scroll so that the new text is visible
          if (r != null) {
            scrollRectToVisible(r);
        } catch (BadLocationException e) {
          System.out.println("Failed to append text: " + e);
    }So every time I call "append" which another classes need to be able to call to update it's current event, It just doesn't work... ? I've been staring at this code for hours, think it's going all matrix on me.

    Isn't this the "*new* to java" forum? I know what error messages are for, if I understood it I wouldn't be here asking the question!!!!
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
         at javax.swing.text.BoxView.updateChildSizes(Unknown Source)
         at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
         at javax.swing.text.BoxView.layout(Unknown Source)
         at javax.swing.text.BoxView.setSize(Unknown Source)
         at javax.swing.text.BoxView.updateChildSizes(Unknown Source)
         at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
         at javax.swing.text.BoxView.layout(Unknown Source)
         at javax.swing.text.FlowView.layout(Unknown Source)
         at javax.swing.text.BoxView.setSize(Unknown Source)
         at javax.swing.text.BoxView.updateChildSizes(Unknown Source)
         at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
         at javax.swing.text.BoxView.layout(Unknown Source)
         at javax.swing.text.BoxView.setSize(Unknown Source)
         at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(Unknown Source)
         at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(Unknown Source)
         at javax.swing.JComponent.getPreferredSize(Unknown Source)
         at javax.swing.JEditorPane.getPreferredSize(Unknown Source)
         at javax.swing.ScrollPaneLayout.layoutContainer(Unknown Source)
         at java.awt.Container.layout(Unknown Source)
         at java.awt.Container.doLayout(Unknown Source)
         at java.awt.Container.validateTree(Unknown Source)
         at java.awt.Container.validate(Unknown Source)
         at javax.swing.RepaintManager.validateInvalidComponents(Unknown Source)
         at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Sourc
    e)
         at java.awt.event.InvocationEvent.dispatch(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)

  • How to automatically populate text boxes from dropdown and tick box options and then sum the results

    Firstly I need to say that I have no knowledge of how to use Javascript.
    I am using the 30 day trial of Adobe Acrobat XP Pro to see if it can be used for a Membership Application Form for the 1st year of membership. This 1st year  has a pro-rata membership fee per month left in the year of application along with a pro-rata postage fee for non-UK members. All of the input will be via basic text boxes with the exception of the application date and overseas postage for which I have created 3 dropdown boxes, one for Day, one for Month and one forYear and for the 2 tick boxes which are there for the applicant to say if they want 2 other options which have a cost attached to them.  I want to populate 2 text boxes from the Month lookup. One of these is for the pro-rata membership fee and the other for the pro-rata overseas postage. The other 2 optional items will be text boxes populated from the tick boxes. Having populated these 4 text boxes I then want to have them automatically summed to give the total to be sent by the applicant.
    I have searched many forums and tried many of the suggested ways of doing it and none of the 4 text boxes are populated.
    Are you able to help me with this?
    Many thanks

    The script solution provided is a "custom calculation JavaScript" not a "simplified field notation".
    The comment at the top of the code:
    // Custom calculate script for text field
    should help clarify the placement location for the code.
    Simplified field notation has a number of specific restrictions. One is that the provided data must be numeric data only.

  • How to automatically repeat text typed in one place

    I am trying to create a template, that will print off a page of very basic labels..no artwork or fancy stuff...just a name and a date...all labels identical for my girlfriends jam and pickle making ...Just jam jar labels that will be printed on sticky labels and printed out.
    I have no idea what terms to each search for in the help or pages User guides... what is this called that will automatically mirror what is typed in one place in other text boxes?  can it even be done?
    I have the basic print setup fine to go betweent the print label borders, but I want to enter the text once, and have it automatically repeated in al the labels.
    What is this called..what function am I looking ..I do not want to Copy and paste in to each text box, I just want to type in one text box and have it repeated in tall the others
    Thanks
    neil

    Hi Guys,
    Thanks for the responses.
    Well yes, I was hoping for a magic 'Repeat Function, and sort of thougth I had used something like that before...but could nto remember what it was called.
    I have been following the answers all day , but have been on and off aircraft all day and have nto been able to find time to try anything out or respond
    I did try the mail merge option...but the pages documetn always had the Mail Merge option greyed out.
    Eaarlier I just created the label i wanted and copied and pasted, but the Alt Option  way is much easier...that combimed with teh Find Replace is the way to go i think for this
    I rarely use any Office apps of any description, so every time I do...maybe once every few months, it is always a chore to remeber how to do things.
    Thanks agsin
    Neil

  • How to create scrolling text  (overflow)

    I think I may have posted this in the wrong forum to begin with...so I'm posting it here.
    I am new to Dreamweaver and new to web creation in general. I am currently working on creating a new website and have run into some issues with large amounts of text. I have created a template for the main layout of my site and have added an editable area within the template. One of the pages I have is our Privacy Policy which is a large amount of text. Here is what I'm trying to do...I need to have the text scroll down only within the editable area. I'm not sure if I need to create a DIV to put stuff in, or a table but I need to have the Overflow function and not have it push the page down.
    Any suggestions or solutions would be great.
    Thanks.

    #DivName {
    height: 400px; /**adjust height & width to suit your needs**/
    width: 100%;
    overflow: auto;
    Working Demo:
    http://alt-web.com/DEMOS/multi-scrollbars.shtml
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • How to automatically scroll continuously to the next page in adobe muse?

    Im building a site which was orginally going to be a one page scroll site but I now what to place the different sections on individual pages to allow easier editing of content. I still want the site look as if it is a continusly scrolling one page site. What I was hoping to do is that when the viewer comes to the end of a section they can continue to scroll down but for it to link to another page, I thought this may be done using anchor points in some way. Any help greatly apprciated! Thanks

    Yes ...
    You need what is called a 'Snap Scroll'  widget ... these widgets use the anchor points as a brake to stop right where they are while swiping or scrolling ... it won't continue down the page until your swipe or scroll again ... it will do this for all anchor points on the page ...
    MuseThemes do one called exactly that ... worth buying their great set of tools for MUSE ... highly recommended ...
    Snap Scroll Widget for Adobe Muse CC - Widget Tutorial by MuseThemes.com - YouTube
    and a free one here from Joseph Angelo Todaro
    Adobe Muse CC Parallax Scrolling Tutorial | Magnetic Scroll Anchors - YouTube
    cheers,
    Gem

  • How to Put scrolling text below masthead?

    Hi,
    I have written a portal component which has got marque text.
    I want to display this marque text just above the top level navigation and below the masthead.
    I added my component in the framework but then when I login only my component is displayed.
    Regards,
    Anagha

    Hi,
        If it is a portal component, you can create iView from the component directly. Open default framework page (DFP) and right click the iView and add it to DFP. Make sure you have set entry point property of iView to Yes. In the DFP, click on page layout radio button and arrange the iView next to masthead and save it. Logout and login back to check. I would advise to check these with copy of DFP since any wrong changes done to standard DFP can cause other portal problems.
    Regards,
    Harini S

  • How to bind scroll positions

    Hi all.
    Do you know how to synchronize scrolling between to JScrollPane containers (for example, in a JSplitPane) using beans binding (in a NetBeans IDE)?
    Thank you in advance.

    Thank you very much, that code works just fine:
    BoundedRangeModel brmMaster = topScrollPane.getHorizontalScrollBar.getModel();
    bottomScrollRange.getHorizontalScrollBar.setModel(brmMaster);Thank you!

  • How do I create dynamic scrolling text in Flash CS5?

    Hi everyone,
    I am a complete newbie to Flash. I'm tyring to build a scrolling text box that automatically scrolls. On mouse over, I want the scrolling to stop so users can click on an item in the text box. All of the items will be tied to external hyperlinks. I want to populate the text box with an external file. I've done some searches on Adobe, but haven't found anything that takes me through the whole process.
    I have the complete Adobe Master Collection. So if this is easier in Flash Catalyst, let me know. I know how to buid a manual scroll box in Flash Catalyst. Could I export this to and add the auto-scrolling?
    Remember, I'm a complete newbie.
    Any help will be greatly appreciated.
    Thanks!

    Thanks again Kglad,
    I really have no preference of Action Script since I don't have any significant experience with either one.
    I'll keep doing searches to see if I can get the information I need.
    Have a great holiday.

  • How do you add a scroll bar to a scrolling text field in a folio?

    I've created iPhone and iPad folios with multiple pages. There are scrolling text fields on each page. The fields scroll as designed, but the scroll bars on the  text fields only appear while actually scrolling. Is there a way to have them always visible so the user knows there is more hidden info? The only bars that are constantly visible are the page scroll bars.  Thanks!

    Why is your content pane null? I thought the content pane was the top-level in all windows? If you want complete control over the location of a list box, you want to set the layout of the content pane to null... the way I almost always do this is the other way around, to create my own panel and use setContentPane instead:
    JPanel content = new JPanel(null);
    JScrollPane scroll = new JScrollPane(myListBox);
    scroll.setBounds(380, 10, 500, 500);
    content.add(scroll);
    setContentPane(content);

  • How to add a scrolling text to display in a web part?

    Hi,
    I have 3 files in a doc library that is been referenced by a web part xml viewer in a page. I am referring only  the xml file.
    WarningMessage.xml
    <script type="text/javascript" src="http://icare/sites/IT/tst/XmlWebParts/WarningMessage/WarningMessage.js"></script>
    WarningMessage.js
    <script type="text/javascript">
    <
    //set the marquee parameters
    function init() { rtl_marquee.start(); }
    var rtl_marquee_Text = 'JavaScript scrolling text';
    var rtl_marquee_Direction = 'left';
    var rtl_marquee_Contents='<span style="font-family:Comic Sans MS;font-size:12pt;white-space:nowrap;">' + rtl_marquee_Text + '</span>';
    rtl_marquee = new xbMarquee('rtl_marquee', '19px', '90%', 6, 100, rtl_marquee_Direction, 'scroll', rtl_marquee_Contents);
    window.setTimeout( init, 200);
    </script>
    and
    xbMarquee.js
    document.writeln('<style type="text/css">');
    document.writeln(' div.marqueecenter1 { text-align: center; }');
    document.writeln(' div.marqueecenter2 { margin- margin-right: auto; }');
    document.writeln(' div.marqueeleft1 { text-align: left; }');
    document.writeln(' div.marqueeleft2 { margin- margin-right: auto; }');
    document.writeln(' div.marqueeright1 { text-align: right; }');
    document.writeln(' div.marqueeright2 { margin- margin-right: 0; }');
    document.writeln('</style>');
    function xbMarquee(id, height, width, scrollAmount, scrollDelay, direction, behavior, html)
      this.id            = id;
      this.scrollAmount  = scrollAmount ? scrollAmount : 6;
      this.scrollDelay   = scrollDelay ? scrollDelay : 85;
      this.direction     = direction ? direction.toLowerCase() : 'left';  
      this.behavior      = behavior ? behavior.toLowerCase() : 'scroll';  
    //  this.name          = 'xbMarquee_' + (++xbMarquee._name);
      this.name          = id;
      this.runId         = null;
      this.html          = html;
      this.isHorizontal = ('up,down'.indexOf(this.direction) == -1);
      if (typeof(height) == 'number')
        this.height = height;
        this.heightUnit = 'px';
      else if (typeof(height) == 'string')
        this.height = parseInt('0' + height, 10);
        this.heightUnit = height.toLowerCase().replace(/^[0-9]+/, '');
      else
        this.height = 100;
        this.heightUnit = 'px';
      if (typeof(width) == 'number')
        this.width = width;
        this.widthUnit = 'px';
      else if (typeof(width) == 'string')
        this.width = parseInt('0' + width, 10);
        this.widthUnit = width.toLowerCase().replace(/^[0-9]+/, '');
      else
        this.width = 100;
        this.widthUnit = 'px';
      // xbMarquee UI events
      this.onmouseover   = null;
      this.onmouseout    = null;
      this.onclick       = null;
      // xbMarquee state events
      this.onstart       = null;
      this.onbounce      = null;
      var markup = '';
      if (document.layers)
        markup = '<ilayer id="' + this.id + 'container" name="' + this.id + 'container" ' +
                 'height="' + height + '" ' +
                 'width="' + width + '"  ' +
                 'clip="' + width + ', ' + height + '" ' +
                 '>' + 
                 '<\/ilayer>';            
      else if (document.body && typeof(document.body.innerHTML) != 'string')
        markup = '<div id="' + this.id + 'container" name="' + this.id + 'container" ' +
                 'style=" ' + 
                 'height: ' + this.height + this.heightUnit + '; ' +
                 'width: ' + this.width + this.widthUnit + '; ' +
                 'clip: rect(0px, ' + this.width + this.widthUnit + ', ' + this.height + this.heightUnit + ', 0px); ' +
                 '">' + 
                 '<div id="' + this.id + '" style="' + 
                 (this.isHorizontal ? 'width:0px;' : '') + // if we scroll horizontally, make the text container as small as possible
                 '">' +
                 (this.isHorizontal ? '<nobr>' : '') +
                 this.html +
                 (this.isHorizontal ? '<\/nobr>' : '') +
                 '<\/div>' +
                 '<\/div>';             
      else 
        markup = '<div id="' + this.id + 'container" name="' + 
                 this.id + 'container" ' +
                 'style=" overflowY: visible; ' + 
                 'height: ' + this.height + this.heightUnit + '; ' +
                 'width: ' + this.width + this.widthUnit + '; ' +
                 'clip: rect(0px, ' + this.width + this.widthUnit + ', ' + this.height + this.heightUnit + ', 0px); ' +
                '">' + 
                 '<\/div>';             
      document.write(markup);  
      window[this.name] = this;
    // Class Properties/Methods
    xbMarquee._name = -1;
    xbMarquee._getInnerSize = function(elm, propName)
      var val = 0;
      if (document.layers)
        // navigator 4
        val = elm.document[propName];    
      else if (elm.style && typeof(elm.style[propName]) == 'number')
        // opera
        // bug in Opera 6 width/offsetWidth. Use clientWidth
        if (propName == 'width' && typeof(elm.clientWidth) == 'number')
          val = elm.clientWidth;
        else
          val =  elm.style[propName];
      else
        //mozilla and IE
        switch (propName)
        case 'height':
           if (typeof(elm.offsetHeight) == 'number')
             val =  elm.offsetHeight;
           break;
        case 'width':
           if (typeof(elm.offsetWidth) == 'number')
             val = elm.offsetWidth;                  
           break;
      return val;
    xbMarquee.getElm = function(id)
      var elm = null;
      if (document.getElementById)
        elm = document.getElementById(id);
      else
        elm = document.all[id];
      return elm;
    xbMarquee.dispatchUIEvent = function (event, marqueeName, eventName)
      var marquee = window[marqueeName];
      var eventAttr = 'on' + eventName;
      if (!marquee)
        return false;
      if (!event && window.event)
        event = window.event;
      switch (eventName)
      case 'mouseover':
      case 'mouseout':
      case 'click':
        if (marquee[eventAttr])
          return marquee['on' + eventName](event);
      return false;
    xbMarquee.createDispatchEventAttr = function (marqueeName, eventName)
      return 'on' + eventName + '="xbMarquee.dispatchUIEvent(event, \'' + marqueeName + '\', \'' + eventName + '\')" ';
    // Instance properties/methods
    xbMarquee.prototype.start = function ()
      var markup = '';
      this.stop();
      if (!this.dirsign)
        if (!document.layers)
          this.containerDiv = xbMarquee.getElm(this.id + 'container')
          if (typeof(this.containerDiv.innerHTML) != 'string')
            return;
          // adjust the container size before inner div is filled in
          // so IE will not hork the size of percentage units 
          var parentNode    = null;
          if (this.containerDiv.parentNode)
            parentNode = this.containerDiv.parentNode;
          else if (this.containerDiv.parentElement)
            parentNode = this.containerDiv.parentElement;
          if (parentNode && 
              typeof(parentNode.offsetHeight) == 'number' && 
              typeof(parentNode.offsetWidth) == 'number')
            if (this.heightUnit == '%')
              this.containerDiv.style.height = 
              parentNode.offsetHeight * (this.height/100) + 'px';
            if (this.widthUnit == '%')
              this.containerDiv.style.width = 
              parentNode.offsetWidth * (this.width/100) + 'px';
          markup += '<div id="' + this.id + '" name="' + this.id + '" ' +
            'style=" ' +
            //(this.isHorizontal ? 'width:0px;' : '') + // if we scroll horizontally, make the text container as small as possible
            '" ' +
            xbMarquee.createDispatchEventAttr(this.name, 'mouseover') +
            xbMarquee.createDispatchEventAttr(this.name, 'mouseout') +
            xbMarquee.createDispatchEventAttr(this.name, 'click') +
            '>' +
            (this.isHorizontal ? '<nobr>' : '') +
            this.html +
            (this.isHorizontal ? '<\/nobr>' : '') +
            '<\/div>';
          this.containerDiv.innerHTML = markup;
          this.div                    = xbMarquee.getElm(this.id);
          this.styleObj     = this.div.style;      
        else /* if (document.layers) */
          this.containerDiv = document.layers[this.id + 'container'];
          markup = 
            '<layer id="' + this.id + '" name="' + this.id + '" top="0" left="0" ' +
            xbMarquee.createDispatchEventAttr(this.name, 'mouseover') +
            xbMarquee.createDispatchEventAttr(this.name, 'mouseout') +
            xbMarquee.createDispatchEventAttr(this.name, 'click') +
            '>' +
            (this.isHorizontal ? '<nobr>' : '') + 
            this.html +
            (this.isHorizontal ? '<\/nobr>' : '') +
            '<\/layer>';
          this.containerDiv.document.write(markup);
          this.containerDiv.document.close();
          this.div          = this.containerDiv.document.layers[this.id];
          this.styleObj     = this.div;
        if (this.isHorizontal && this.height < xbMarquee._getInnerSize(this.div, 'height') )
          this.height = xbMarquee._getInnerSize(this.div, 'height')
          this.containerDiv.style.height = this.height + this.heightUnit;
          this.containerDiv.style.clip = 'rect(0px, ' + this.width + this.widthUnit + ', ' + this.height + this.heightUnit + ', 0px)';
        // Start must not run until the page load event has fired
        // due to Internet Explorer not setting the height and width of 
        // the dynamically written content until then
        switch (this.direction)
        case 'down':
          this.dirsign = 1;
          this.startAt = -xbMarquee._getInnerSize(this.div, 'height');
          this._setTop(this.startAt);
          if (this.heightUnit == '%')
            this.stopAt = this.height * xbMarquee._getInnerSize(this.containerDiv, 'height') / 100;
          else
            this.stopAt  = this.height;
          break;
        case 'up':
          this.dirsign = -1;
          if (this.heightUnit == '%')
            this.startAt = this.height * xbMarquee._getInnerSize(this.containerDiv, 'height') / 100;
          else     
            this.startAt = this.height;
          this._setTop(this.startAt);
          this.stopAt  = -xbMarquee._getInnerSize(this.div, 'height');      
          break;
        case 'right':
          this.dirsign = 1;
          this.startAt = -xbMarquee._getInnerSize(this.div, 'width');
          this._setLeft(this.startAt);
          if (this.widthUnit == '%')
            this.stopAt = this.width * xbMarquee._getInnerSize(this.containerDiv, 'width') / 100;
          else    
            this.stopAt  = this.width;
          break;
        case 'left':
        default:
          this.dirsign = -1;
    if (this.widthUnit == '%')
    this.startAt = this.width * xbMarquee._getInnerSize(this.containerDiv, 'width') / 100;
    else  
    this.startAt = this.width        
    this._setLeft(this.startAt);
    // this.stopAt  = -xbMarquee._getInnerSize(this.div,'width')*2;
    // this method does not work very well with FireFox.  offsetWidth property used in this function returns the absolute width of the div container
    // instead of the new offsetWidth when innerHTML is added or when the div becomes wider. To overcome this a new span element is added to 
    // the document body to measure the new offsetwidth and then it is removed.
    var temp_span = document.createElement('span');     
    temp_span.id = 'span_' + this.div.id;
    temp_span.innerHTML = this.html;
    document.body.appendChild(temp_span);                
    this.stopAt = - temp_span.firstChild.firstChild.offsetWidth;
    document.body.removeChild(temp_span);            
          break;
        this.newPosition          = this.startAt;
        this.styleObj.visibility = 'visible'; 
      this.newPosition += this.dirsign * this.scrollAmount;
      if ( (this.dirsign == 1  && this.newPosition > this.stopAt) ||
           (this.dirsign == -1 && this.newPosition < this.stopAt) )
        if (this.behavior == 'alternate')
          if (this.onbounce)
            // fire bounce when alternate changes directions
            this.onbounce();
          this.dirsign = -this.dirsign;
          var temp     = this.stopAt;
          this.stopAt  = this.startAt;
          this.startAt = temp;
        else
          // fire start when position is a start
          if (this.onstart)
            this.onstart();
          this.newPosition = this.startAt;
      switch(this.direction)
        case 'up': 
        case 'down':
          this._setTop(this.newPosition);
          break;
        case 'left': 
        case 'right':
        default:
          this._setLeft(this.newPosition);
          break;
      this.runId = setTimeout(this.name + '.start()', this.scrollDelay);
    xbMarquee.prototype.stop = function ()
      if (this.runId)
        clearTimeout(this.runId);
      this.runId = null;
    xbMarquee.prototype.setInnerHTML = function (html)
      if (typeof(this.div.innerHTML) != 'string')
        return;
      var running = false;
      if (this.runId)
        running = true;
        this.stop();
      this.html = html;
      this.dirsign = null;
      if (running)
        this.start();
    // fixes standards mode in gecko
    // since units are required
    if (document.layers)
      xbMarquee.prototype._setLeft = function (left)
        this.styleObj.left = left;    
      xbMarquee.prototype._setTop = function (top)
        this.styleObj.top = top;    
    else
      xbMarquee.prototype._setLeft = function (left)
        this.styleObj.left = left + 'px';    
      xbMarquee.prototype._setTop = function (top)
        this.styleObj.top = top + 'px';    
    I have nothing displaying in the web-part. How can I make this to work?

    This is how i was able to do it. Edit html source.
    <div align="center"><marquee id='scroll_news4' bgcolor=#ff9966 "><font color="#000000" size="+1" ><strong>Outlook is down! IT is working on it! </strong></font></marquee></div>
    <input type='Button' value='Stop' id ='b1' onClick='button_click()';>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function button_click()
    if(document.getElementById('b1').value=="Start"){
    document.getElementById('b1').value="Stop";
    document.getElementById('scroll_news4').start();
    }else{
    document.getElementById('b1').value="Start";
    document.getElementById('scroll_news4').stop();
    // End -->
    </script>

  • How can I use a table as source for scrolling text

    Hi,
    I have a javascript scolling news on our portal page and anytime I need to update the news I have to update the portlet. Is there a way to use a database table to store the news and get it displayed automatically (as a scrolling text) after committing the transaction.
    Thanks,
    Leonard

    What do you mean by updating the portlet - page refresh?
    The nature of HTTP is that the client has to initiate the communication. As long as the browser doesn't submit a new request for the page, the content won't refresh.
    There are tricks, though that you may consider... such as placing an iframe on your portal page that "pings" the server and checks whether there's any change on the server side. Another option could be using an applet.

  • How to add a scrolling text in portrait with iMovie

    how to add a scrolling text in portrait with iMovie

    This is how i was able to do it. Edit html source.
    <div align="center"><marquee id='scroll_news4' bgcolor=#ff9966 "><font color="#000000" size="+1" ><strong>Outlook is down! IT is working on it! </strong></font></marquee></div>
    <input type='Button' value='Stop' id ='b1' onClick='button_click()';>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function button_click()
    if(document.getElementById('b1').value=="Start"){
    document.getElementById('b1').value="Stop";
    document.getElementById('scroll_news4').start();
    }else{
    document.getElementById('b1').value="Start";
    document.getElementById('scroll_news4').stop();
    // End -->
    </script>

  • How to scroll text.

    I want to scroll text on a touch device. But i have no idea how to do this. I read up on adobe that a mouse event will work, but a touch point could also be used, then they lost me talking about item rendering.
    Can someone help me figure out how to scroll text on a touch enabled device?

    You don't want to use just a while loop because once you get into the loop, it'll stay in there until you break out. Nothing else will be allowed to process. You'll want to use a Thread with a while loop inside.
    I don't know if thise code will work. just wrote it off the top of my head. But something like that. You'll probably have to put extra white space in at the beginning of your scrollText so it starts on the far right side.
    class ScrollArea extends JTextField implements Runnable
    private Thread myThread;
    private int i;
         public ScrollArea()
              myThread = new Thread(this);
              int scrolDist = textToScroll.length() + this.getColumns();
              i = 0;
         public void Run()
              int scrolDist = textToScroll.length() + this.getColumns();
              while(true)
                    if(i == scrolDist)
                         i = 0;
                    int scrolDist = textToScroll.length() + this.getColumns();
                    this.setText(textToScroll.substring(i, scrolDist)
                    i++;
         }

Maybe you are looking for