Jpanel, jframe & jscrollpane related problems

L

ludaekipa

Hi

This is my code:

Grafi smart1 = new Grafi(nn, testing, n_archi, max*160+60);
int width1 = 0;
int height1 = 0;
width1=max*160+60;
if (ncompat==1) {
height1=(int)((nn*30))+60;
} else {
height1=(int)((nn*30)/(ncompat-1))+60;
}
smart1.setPreferredSize(new Dimension(width1, height1));
JScrollPane scrollpane1 = new JScrollPane(smart1);
JFrame f1 = new JFrame("MyFindeR - Direct Strand");
f1.setContentPane(scrollpane1);
f1.setSize(800, 600);
f1.setVisible(true);

Grafi is a class which extends JPanel, and smart1 is an instance of Grafi on
which there are drawed some ractangles and lines. My smart1 is very huge
and everytime I use repaint(), it takes 7-8 seconds to repaint it all. So,
I would like to use the repaint(x,y,width,height) feature, and repaint only
the visible part of smart1. In that case width and height would be 800 and
600 (frame size), but, how can I find x & y? I need x and y of smart1, that
corresponds to the point (0,0) of the frame. Is there a way to find them?
Thnx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top