Jpanel, jframe & jscrollpane related problems

Discussion in 'Java' started by ludaekipa, May 4, 2004.

  1. ludaekipa

    ludaekipa Guest

    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
    ludaekipa, May 4, 2004
    #1
    1. Advertising

  2. See
    JScrollPane.getViewport().getViewPosition();

    --
    Luca Paganelli
    ICQ# 52629494
    Luca Paganelli, May 4, 2004
    #2
    1. Advertising

  3. ludaekipa

    ludaekipa Guest

    Luca Paganelli wrote:

    > See
    > JScrollPane.getViewport().getViewPosition();
    >


    It works. thnx.
    ludaekipa, May 4, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike
    Replies:
    5
    Views:
    5,001
  2. Andreas Beresko

    Add a JPanel to a JPanel...

    Andreas Beresko, Jul 14, 2004, in forum: Java
    Replies:
    6
    Views:
    26,971
  3. McMatt
    Replies:
    2
    Views:
    816
    McMatt
    Feb 23, 2007
  4. Raphael Jolivet

    [JPanel] Drop Down JPanel

    Raphael Jolivet, Jul 18, 2008, in forum: Java
    Replies:
    1
    Views:
    1,512
    John B. Matthews
    Jul 18, 2008
  5. t1m1976
    Replies:
    1
    Views:
    2,397
    t1m1976
    Nov 7, 2010
Loading...

Share This Page