DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2005
    Posts
    12

    Question Need Scroll Bar To Go Down On Chat Program

    Hi, i have inserted a scoll bar like so:

    txArea = new TextArea ("", 6, 40, TextArea.SCROLLBARS_VERTICAL_ONLY);

    but when a new message is receieved the scrollbar goes up, i would like it to stay at the bottom so it is possible to view the most recent recieved message.

    any help would be greatly appreciated!

    thanks


  2. #2
    Join Date
    Oct 2005
    Posts
    107
    I've used JTextPane and it works like you want

    JTextPane chatPane = new JTextPane();
    JScrollPane scrollPane = new JScrollPane(chatPane);

    then you can append lines to it like so

    Code:
    public void appendLine(String line){
    			Document doc = chatPane.getDocument();
    			int end = doc.getLength();
    			line += "\n";
    
    			doc.insertString(end, line, regularStyle);
    				
    	}
    Last edited by Joe Beam; 12-08-2005 at 02:46 AM.

Similar Threads

  1. Controlling the scroll bar in a Panel
    By Bogdan in forum .NET
    Replies: 0
    Last Post: 06-24-2002, 03:44 PM
  2. Scroll Bar creation
    By shawn in forum Java
    Replies: 0
    Last Post: 11-02-2001, 08:42 AM
  3. Script for scrolling
    By Mark in forum Web
    Replies: 3
    Last Post: 08-30-2001, 11:45 AM
  4. Horizontal scroll bar for a list box
    By Anitha in forum Web
    Replies: 1
    Last Post: 05-25-2001, 10:41 PM
  5. scroll bar dosent move automatically
    By mbd7031 in forum Java
    Replies: 2
    Last Post: 08-01-2000, 03:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links