Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2009
    Posts
    14
    Rep Power
    0

    Exclamation Need help regarding the Automatic scrolling the jPanel

    Hi Friends,

    Currently am building a small app where the Jpanel as the scroll but i want this to get auto scrolling based on the action event from a button and by set timing...

    Can you please help me out in this

    Thanks in advance

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Need help regarding the Automatic scrolling the jPanel

    Quote Originally Posted by naveen.dpt2007 View Post
    Can you please help me out in this
    Sure thing. But where's what you've tried, and what's the specific issue with which you need help?

    As your post stands, it looks more like "Will one of you suckers do this for me?" than "Can you please help" -- and even that can't work, what with the paucity of detail.

    To get better help sooner, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates your specific problem.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Join Date
    Aug 2009
    Posts
    14
    Rep Power
    0

    Default Re: Need help regarding the Automatic scrolling the jPanel

    Thanks for the Darryl,

    When i posted this i was not aware how to have a auto scroll option now i found the code and its getting done just adding the code sample for the review, wheather am i doing correct

    int panelMaxY = (int)imgPanel.getBounds().getMaxY(); // getting the Max size of the Panel area
    int scrolViewY = (int)scrollPane.getViewport().getViewPosition().ge tY();
    log.info("The scrol panel height is : "+panelMaxY);
    log.info("The scrol View Y is : "+scrolViewY);

    if(scrolViewY < panelMaxY){
    log.info("The scrol View Y is : "+scrolViewY);
    scrollPane.getViewport().setViewPosition(new Point((int)scrollPane.getViewport().getViewPositio n().getX(),(int)scrollPane.getViewport().getViewPo sition().getY()+180));
    }else if (scrolViewY > panelMaxY){
    log.info("The scrol View Y is More : "+scrolViewY);
    scrollPane.getViewport().setViewPosition(new Point((int)scrollPane.getViewport().getViewPositio n().getX(),(int)scrollPane.getViewport().getMaximu mSize().width));
    }

    am setting a timer for moving this scroll based on the set... Please suggest is this correct or any best way

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Need help regarding the Automatic scrolling the jPanel

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Join Date
    Aug 2009
    Posts
    14
    Rep Power
    0

    Default Re: Need help regarding the Automatic scrolling the jPanel

    Java Code:
    int panelMaxY = (int)imgPanel.getBounds().getMaxY(); // getting the Max size of the Panel area
    int scrolViewY = (int)scrollPane.getViewport().getViewPosition().ge tY();
    log.info("The scrol panel height is : "+panelMaxY);
    log.info("The scrol View Y is : "+scrolViewY);
    
    if(scrolViewY < panelMaxY){
    log.info("The scrol View Y is : "+scrolViewY);
    scrollPane.getViewport().setViewPosition(new Point((int)scrollPane.getViewport().getViewPositio n().getX(),(int)scrollPane.getViewport().getViewPo sition().getY()+180));
    }else if (scrolViewY > panelMaxY){
    log.info("The scrol View Y is More : "+scrolViewY);
    scrollPane.getViewport().setViewPosition(new Point((int)scrollPane.getViewport().getViewPositio n().getX(),(int)scrollPane.getViewport().getMaximu mSize().width));
    }

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Need help regarding the Automatic scrolling the jPanel

    Where's that SSCCE?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Scrolling in JPanel makes the content erased
    By Mathi_r in forum Java Applets
    Replies: 3
    Last Post: 07-28-2011, 02:01 PM
  2. Replies: 4
    Last Post: 06-11-2011, 11:59 PM
  3. automatic ENTER?
    By glina126 in forum New To Java
    Replies: 3
    Last Post: 02-25-2011, 07:08 AM
  4. Automatic scrolling of JScrollPane
    By chayan in forum AWT / Swing
    Replies: 2
    Last Post: 07-03-2010, 05:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •