Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-09-2002, 12:08 AM   #1 (permalink)
abc123
bloomberg
 
abc123's Avatar
 
Join Date: Jun 2002
Location: bloomberg
Posts: 263
abc123 is on a distinguished road
Send a message via AIM to abc123 Send a message via Yahoo to abc123
java again, JScrollPane's



I have given a JTextArea to a JScrollPane so i can scroll it, but, because the Jtextarea (x) receives data without me typing it in it, it will not automatically adjust the "viewport" so i permenantly stuck at the top of the damn thing

i have tried looking in the api numerous times but i can't figure out how to re-adjust it

i briefly tried getting the number of lines in x (x.getLineCount()) but this gave me very weird numbers in a rather odd pattern so i am completely confused

anyone got any clues?
__________________
-- bloomberg.
abc123 is offline   Reply With Quote
Old 08-10-2002, 07:15 PM   #2 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 287
technobard is on a distinguished road
My Swing knowledge is severely limited, so take this with a grain of salt. From your text it looks like you might be using a constructor where the only parameter is the String to populate the JtextArea. There is another constructor which allows you to specify an initial row, column and text. You might try that.

Also, can you post the code (or a suitable portion)?
technobard is offline   Reply With Quote
Old 08-10-2002, 08:17 PM   #3 (permalink)
abc123
bloomberg
 
abc123's Avatar
 
Join Date: Jun 2002
Location: bloomberg
Posts: 263
abc123 is on a distinguished road
Send a message via AIM to abc123 Send a message via Yahoo to abc123
heh, i also hate the gui area of java, anyhow here is some code:

Code:
private JTextArea output; //the text area in question

output = new JTextArea(); //constructing it in another method somewhere
p.add(new JScrollPane(output), GDC); //adding it to my JPanel with GridBagConstraints

// in an inner class...
inData = in.readLine().trim().toLowerCase();
print(output, inData); //a print method i have

private void print(JTextArea jt, String s) //the print method
{
        jt.setText(jt.getText()+s+"\n");
}
that is pretty much all the neccessary code, im not sure if it makes any sense


but basically the inner class area is always calling the "print" method while data is coming in from the socket (in).. it may be better to use jt.append in the print method so i will try that now but i don't think that'll fix the prob

thanks for ur help

--- EDIT ---
.append() did nothing
__________________
-- bloomberg.
abc123 is offline   Reply With Quote
Old 08-11-2002, 03:20 PM   #4 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 287
technobard is on a distinguished road
I think I get it. It sounds like you need to refresh the JScrollPane after updating it. You could either use a listener or just call the JScrollPane.revalidate() method followed by the .repaint() method. Also, I still think you need to initialize the size of either the JTextArea or of the JScrollPane. I saw some reference to making sure you do this on the Sun website, but not what the consequences are. JScrollPane.setPreferredSize(rowsize, columnsize) can be used, for example.

Good luck. Let me know how it turns out.
technobard is offline   Reply With Quote
Old 09-24-2002, 04:48 AM   #5 (permalink)
abc123
bloomberg
 
abc123's Avatar
 
Join Date: Jun 2002
Location: bloomberg
Posts: 263
abc123 is on a distinguished road
Send a message via AIM to abc123 Send a message via Yahoo to abc123
fixed it with this:

Code:
JScrollPane jsOut = new JScrollPane(yep);
jsOut.getVerticalScrollBar().setValue(jsOut.getVerticalScrollBar().getMaximum());
__________________
-- bloomberg.
abc123 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Developer Position in Kansas City justplaindoug Java 0 10-29-2004 12:52 PM
JAVA Hobbyists Wanted emteam Java 0 08-29-2004 12:27 PM
IBM urges Sun to make Java open source redhead Code Newbie News 0 03-01-2004 11:39 PM


All times are GMT -8. The time now is 01:39 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting