Need Scroll Bar To Go Down On Chat Program


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Need Scroll Bar To Go Down On Chat Program

  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 03:46 AM.

Similar Threads

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

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center