Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2006

Tip: Looking for answers? Try searching our database.

Scrollpane and TextArea pls help asap

Thread view: 
al_khalifah@gawab.com - 08 Feb 2006 07:06 GMT
Hi i have coded a chatroom client that connects tot he server i am
using a JtextArea with JscrollPane. The user inputs a sentence in the
text field when they press enter it goes to the server and the server
send it tot he client the client diplays it int he textarea ok the
scroll bars are there but they dont scrol down for the latest entry of
the user. Just think of any chat room powered by java on the net the
user never has to scrold own for every new entry the chat is like auto
scroll pls help , Thanks

Below is some of the code
text = new JTextArea(10,34); myPane.add(text);
sp = new JScrollPane(text);
sp.setPreferredSize(new Dimension (350,200));
myPane.add(sp, BorderLayout.CENTER);
botPanel = new JPanel();
Reply With Quote
Benoit Peltier - 08 Feb 2006 12:14 GMT
Did not test it but here's what I would try,

After you added the lines fecth the scrollpane vertical scroll bar and set
it value to its maximum :

JScrollPane scrollPane = new JScrollPane( textArea );
...
// add your lines of text in the textArea
...
// set scroll bar
JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar();
verticalScrollBar.setValue( verticalScrollBar.getMaximum() );
...

Like I said, I have not tried it. But it's the way I would go.
Hope it helps,

Benoit

> Hi i have coded a chatroom client that connects tot he server i am
> using a JtextArea with JscrollPane. The user inputs a sentence in the
[quoted text clipped - 12 lines]
> botPanel = new JPanel();
> Reply With Quote


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.