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

    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!


  2. #2
    Join Date
    Oct 2005
    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

    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

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
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

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