Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Scrolling in Java  RSS feed

 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
How many items at a time can scrolling in Java handle?? For example if I have a JList or a JTable, what is the maximum number of rows that JTable or JList scroll list? Will it keep scrolling for infinity.
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How many items at a time can scrolling in Java handle?? For example if I have a JList or a JTable, what is the maximum number of rows that JTable or JList scroll list?
This depends on the JComponent view. You can get and set the unit and block increments on either/both of the horizontal and vertical scrollBars of a JScrollPane. See the JScrollPane class api comments section which contains a link to the tutorial page "How to Use Scroll Panes" where you can get the details.
Will it keep scrolling for infinity
I'm not sure what you mean by this. It should scroll to the end of the content/view; to the bottom of the child JComponent.
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is what I am exactly looking for.

The JList component uses the ListModel interface. This interface has method getSize() that has a return type of int,which means at most (2 to the power 32) of elements can the JList view. What I am looking for is that I want to be able to do is make the JLast be able to view more than that (2 to the power 64).

Is this possible.
 
Campbell Ritchie
Marshal
Posts: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not 2^32, but 2^31 - 1 which is the largest possible value of an int.
DefaultListModel has a private Vector member, and Vector has a protected Object[] member. I can't find anywhere in the API for Vector where it says there is a maximum size, nor does the JLS Arrays chapter mention a maximum size.

So I don't see why you can't have a larger list.





























Just buy a larger screen
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
The DefaultListModel implements the ListModel interface. This interface represents the functionality of a list model. This interface has a getSize method, and this method returns an int data type.Which means any list can have at maximum (2 ^ 32 -1) of elements.What I am looking for is that I want a value greater than that, for example (2 ^ 64).
 
Campbell Ritchie
Marshal
Posts: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from Khaled Mahmoud
Which means any list can have at maximum (2 ^ 32 -1) of elements.
Does it? I have already told you there is no mention of a maximum size. Look at a related class, ArrayList. It says
Each ArrayList instance has a capacity. The capacity is the size of the array used to store the elements in the list. It is always at least as large as the list size.
It doesn't say anything about maximum size. But have you bought your new big screen? Have you tried to add > 2^31 elements? Can you do it without an OutOfMemoryError? What do your friends say about somebody who tries that?
 
Paul Clapham
Sheriff
Posts: 22472
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see much practical use for a JList that can display over 2 billion entries.
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the following code sample written by Hans Muller, the author of the JList class.



In the list model, the maximum number of elements it can have is about
(2 ^ 32) / 2.Why is it that number. Because the get size method is int. The JList can deal with at maximum 2 ^ 32 /2. Why /2 because int is a signed data type, and half of those 2^32 will go for negative numbers.

What I want is I do want the ListModel to be able to handle elements more than that. For example 2 ^ 64.


Why I do want that??


Because I have been discussing with someone with in Java we can modify the JList that can handle more that this limit. For example 2 ^ 64.

Did you get my idea
[ April 13, 2007: Message edited by: Khaled Mahmoud ]
 
Campbell Ritchie
Marshal
Posts: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To repeat what I said earlier: try it. See what happens
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would you please place the code to try?
 
Campbell Ritchie
Marshal
Posts: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Khaled Mahmoud:
Would you please place the code to try?
. . .
Life is the biggest school
Can you really not work it out for yourself? Thisis what I tried for an ArrayList without a GUI
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!