Forums Register Login

Adding Scrollbar for Applet contains more that 5000 lines

+Pie Number of slices to send: Send
Hi,

I am trying to add scroll bar for a applet contains more than 5000 lines.I added the jscroll pane and set the preferred size 100000. I am able to see nearly only 1500 entries.I am not sure how to associate a scroll bar to applet to see all the lines added in applet.Appreciate the hellp.Thank you.

Code
----

[ December 26, 2008: Message edited by: Rayner ]
+Pie Number of slices to send: Send
I recommend avoiding "magic" numbers with use of constants and using the information available to you to help set your proper size:

[ December 26, 2008: Message edited by: pete stein ]
+Pie Number of slices to send: Send
Hi ,

Thank you Rob Prime.I will use the code tags here after.

pete stein thank you very much for that reply.I am now able to see the all the lines.I am new to java and i will use the constants as you mentioned in the post.

I have one more doubt.My requiremt is to design a applet which should draw the lines (the line is a packet transmission).When i click particular line i have to show some information on tooltip.The range of line get displayed could be 100 to 90000.I am using applet beacause it has to be viewable in both the browser and the application.My question is whether i have yo use jpane or canvas.Which one suits the above requirement in a better way.Thank you.

Regards
Ganesh M
[ December 26, 2008: Message edited by: Rayner ]
+Pie Number of slices to send: Send
 

Originally posted by Rayner:
I have one more doubt.My requiremt is to design a applet which should draw the lines (the line is a packet transmission).When i click particular line i have to show some information on tooltip.The range of line get displayed could be 100 to 90000.I am using applet beacause it has to be viewable in both the browser and the application.My question is whether i have yo use jpane or canvas.Which one suits the above requirement in a better way.



I think that Swing (JPanel, JApplet, JFrame) is much more robust than AWT (Canvas, Applet, Frame), and thus Swing is the way to go. I recommend that you do everything in a JPanel and that the JApplet class be nothing more than a driver class that places the main JPanel in JApplet's contentPane. Your JScrollPane will hold a JPanel, and you may wish that this inner JPanel use GridLayout(0, 1) (1 column, many rows) to hold many rows of a JComponent (this could be JLabel, or JPanel , or JWhatever), each with it's tooltip set properly.
+Pie Number of slices to send: Send
pete stein,I will try with what you have suggested.Thank you.

Regards
Ganesh M
+Pie Number of slices to send: Send
Hi,

Now i have progressed with the Jpanel and JApplet.Its working fine.In my case i have to do some calculation for string parsing to get some information need to be displayed along with the lines while i am drawing.This work fine for 500 to 1000 line.If it crosses above 4000 lines it slows down the application.Usually the expected line may range from 4000 to 50000.

It seems that for every scrolling it redraws the complete set of lines again.Instead of doing so is it possible to draw a specific region based on the scroll bar movement.Kindly recommend some good way of doing this.
Thanks in advance.

Regards
Ganesh
+Pie Number of slices to send: Send
This suggests to me that you are doing something very costly in terms of CPU and time from within a paint or paintComponent method. Perhaps you need to adjust this: either limit your painting to that which is visible, or (and this is what I prefer) use separate components such as a JLabel or JPanel array and do painting within each component of the array when needed.

If these suggestions don't help you, you may want to post a small compilable program that demonstrates what you are trying to do and what problems you are having. This is called an SSCCE and information on how to create one can be found here:
SSCCE -- Short, Self Contained, Correct (Compilable), Example
+Pie Number of slices to send: Send
pete stein once again thanks for the reply.I was out for vacation leave.Thats why i am not able to reply soon.
Thanks for your suggestion.Now i have optimized the code for painting which works fine.The acutal problem was
the i had stored the information in hashmap,In paint procedure call i removed all the entries and once again stored the
structure.

Regards
Ganesh M
yeah, but ... what would PIE do? Especially concerning this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4062 times.
Similar Threads
scrollpane
increase size of scrollpane at run time
enabling the scrollbar when components are dynamically added in jpanel
Text canvas vertical scroll
A question about JScrollPane. Thanks in advance!
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:00:30.