I've run into an rather irritating problem in java. I have a program that runs a bunch of simulations in java, there is a lot of data generated and it's all displayed on "graph" objects. I created a component called "Graphs" that displays a long list of these "graph" objects using a GroupLayout and placed it inside a Jscrollpane.
The problem i'm having is the end half of "Graphs" is being cut off. The maximum size that the component can get to is 32,767 Which happens to be the same as 2^15 − 1 (maximum size of a signed 16 bit number). It would seem that component size is being stored as a 16 bit signed number and not a 32 bit integer as I first thought.
The question I have is thus.
Is there any way of changing the way java stores the size of components, and therefore create components larger than this size?
If not what would the best way to tackle this problem? I would like to show all this info on one panel. Even if I were to "stack" "Graphs" components on top of each other, the parent component would still end up outside of the maximum size.
Thanks in advance.
See the related question, Why doesn't Java support unsigned ints?.
You can work around the limitation by displaying your graphs in a
JTable will only render the cells that are currently visible. Ideally, you should store the values for your graphs in a
TableModel, respectively, and implement the corresponding custom
If you just want a proof-of-concept first, you can shove the Graph
Components directly into a
DefaultTableModel, and use a renderer whose
get*CellRendererComponent(...) method returns the Graph.
I know this approach might be a bit harder to accomplish but it will work a better than your currrent approach. Try to add a scrollbar next to your Graph, not a scrollpane. Update the content of your Graph dynamically, according to the position of the scrollbar, by adding a listener to the scrollbar.
Graphclass and modify your member datatypes to be larger (BigInteger)? My apologies if that's not an option - collinjsimpson 2012-04-03 22:11