aspose file tools*
The moose likes Beginning Java and the fly likes listener for when a list scrolls off the screen? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "listener for when a list scrolls off the screen?" Watch "listener for when a list scrolls off the screen?" New topic
Author

listener for when a list scrolls off the screen?

Charley Abrams
Greenhorn

Joined: Nov 15, 2008
Posts: 6
Is there some sort of listener in Java that indicates when a looped list scrolls off the screen? Or, as an alternative, is there a command that counts the lines available on a users screen? If so, could someone please let me know what they are?

Thank you!
[ November 15, 2008: Message edited by: CodeCharley CodeAbrams ]
Charley Abrams
Greenhorn

Joined: Nov 15, 2008
Posts: 6
Yes, I did have trouble with the screen name, it would not except Charley Abrams, as I had submited it more then once, due to other problems.

I hope that does not discourage any help that I would have otherwise recieved.

I was able to fix my name, as you can see.

[ November 15, 2008: Message edited by: Charley Abrams ]
[ November 15, 2008: Message edited by: Charley Abrams ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

The ancient forum software is finicky, especially during registration. Thanks for changing it promptly.

Now, as to your question. What do you mean by "screen"? A command-line terminal emulator (like a DOS window)?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Charley Abrams
Greenhorn

Joined: Nov 15, 2008
Posts: 6
Originally posted by Bear Bibeault:
The ancient forum software is finicky, especially during registration. Thanks for changing it promptly.

Now, as to your question. What do you mean by "screen"? A command-line terminal emulator (like a DOS window)?


Yes, a DOS or command prompt window. I have a for loop, that if it continues to scroll off the screen, I need it to " use loops to display a partial list, hesitate, and then display more of the list."

I believe to "hesitate" I will use Thread.sleep(4000), executed when I find a way to determin when the list has reached the end of the screen.
[ November 15, 2008: Message edited by: Charley Abrams ]
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

Hi Charley,

I can't think of way to get the maximum number of lines for a generic terminal window in Java. Even worse for most cases besides DOS the user may resize the window.

I don't know what exactly your program should do but the simplest solution I have in mind is to combine your application with a standard tool like "more" to page the output directly in the operating system. Of course this solution is not very portable but it depends on your requirements if this is allowed.

Other possibilities could be a configurable screen height or to use the guaranteed minimum number of lines all possible terminal windows provide.

Hope this helps

Marco
Charley Abrams
Greenhorn

Joined: Nov 15, 2008
Posts: 6
Thanks for the suggestions, it does help.

Here is my current sollution, unfortunatly it does not account for the various window sizes:

if (currentMonth % 15 == 0){
Thread.sleep(4000);
System.out.println("I guess I will divide it like this?");
}
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

I think there's no better way if you want to use only pure Java. As I wrote a small enhancement could be to make the number of lines per page configurable for the user...

Is it important for your application to be very portable to different operating systems? With a one liner shell script which pipes the output through "more" or "less" you would be done on Linux and the application would always use the whole screen. A simple .bat file on Windows would make the job, too.

Marco
Charley Abrams
Greenhorn

Joined: Nov 15, 2008
Posts: 6
That seems to be out of the scope of my assignment,

I think if it is not possible to determin the number of lines, or when the program begins to scroll then I should be able to get by with what have,

I think the assignment was writen poorly.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
what about printing a message every 25 (or whatever) lines
"press enter to continue"
and the program halts waiting for enter (rather than a timer)

Charley Abrams
Greenhorn

Joined: Nov 15, 2008
Posts: 6
some of the other classmates seem to be doing that, but the assignment says to make it "hesitate", which unless in coding "hesitate" is different(which is always a posibility), I think the timer method best fullfills the needs of the assignment.
 
wood burning stoves
 
subject: listener for when a list scrolls off the screen?