Solved

Forced Scroll

Posted on 2001-07-17
10
211 Views
Last Modified: 2008-03-03
I have a scrollpane that I need to reposition. I have tried to change the value of the Vertical scrollbar but this was unsuccessful. This is a sample of the code that I used.
getOESScrollPane().getVerticalScrollBar().setValue(2);

Thanks in advance for your help
0
Comment
Question by:xaun
10 Comments
 
LVL 4

Accepted Solution

by:
sdussinger earned 100 total points
ID: 6291236
Try this:

Point pos = getOESScrollPane().getViewport ().getViewPosition ();

pos.y -= 50;

getOESScrollPane().getViewport ().setViewPosition (pos);

This will scroll the viewport vertically by 50 pixels.

--Steve
0
 
LVL 4

Expert Comment

by:sdussinger
ID: 6291243
Try this:

Point pos = getOESScrollPane().getViewport ().getViewPosition ();

pos.y -= 50;

getOESScrollPane().getViewport ().setViewPosition (pos);

This will scroll the viewport vertically by 50 pixels.

--Steve
0
 
LVL 4

Expert Comment

by:sdussinger
ID: 6291245
Try this:

Point pos = getOESScrollPane().getViewport ().getViewPosition ();

pos.y -= 50;

getOESScrollPane().getViewport ().setViewPosition (pos);

This will scroll the viewport vertically by 50 pixels.

--Steve
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 4

Expert Comment

by:sdussinger
ID: 6291249
Sorry. It seems that refreshing this page after generating a response causes the response to be posted more than once.

Guess I won't do that again!!

--Steve
0
 

Author Comment

by:xaun
ID: 6294282
Thanks for your input Steve but that solution didn't work. I tried it once before I posted the question then again after your suggestion.
0
 
LVL 4

Expert Comment

by:sdussinger
ID: 6294943
That's odd. I tested it on my machine and it works fine.

I've included the test program that I used. If you have a slow internet connection, it'll take a while to load since its grabbing an image to scroll, so be patient.

Can you post your code here, so we can try and figure out why it fails for you?

Here's the code:

----------------------------------------------------------
public class JFrame extends javax.swing.JFrame
{

    public JFrame()
    {
        initComponents ();
        pack ();
    }

    private void initComponents()
    {
        jScrollPane1 = new javax.swing.JScrollPane();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        addWindowListener(new java.awt.event.WindowAdapter()
         {
          public void windowClosing(java.awt.event.WindowEvent evt)
          {
              exitForm(evt);
          }
         }
                 );
       
       
     try
         {
          java.net.URL url = new java.net.URL ("http://thebishop.ne.mediaone.net/photos/images/DSCN0159.JPG");

          jLabel1.setIcon(new javax.swing.ImageIcon(url));
         }
     catch (Exception e)
         {
         }

     jLabel1.setText("jLabel1");
     jScrollPane1.setViewportView(jLabel1);
           
        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
         
        jButton1.setText("jButton1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
              jButton1ActionPerformed(evt);
          }
         } );
       
        getContentPane().add(jButton1, java.awt.BorderLayout.SOUTH);
       
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
    {
     java.awt.Point pt = jScrollPane1.getViewport().getViewPosition ();
     
     System.out.println (pt);
     
     pt.y -= 50;
     
     jScrollPane1.getViewport ().setViewPosition (pt);
    }

    private void exitForm(java.awt.event.WindowEvent evt)
    {
     System.exit (0);
    }

    public static void main (String args[])
    {
        new JFrame ().show ();
    }


    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JButton jButton1;

}

----------------------------------------------------------

--Steve
0
 
LVL 4

Expert Comment

by:sdussinger
ID: 6294948
Whenever you click on the button at the bottom of the panel, the image will scroll down by 50 pixels.

--Steve
0
 
LVL 4

Expert Comment

by:sdussinger
ID: 6382880
Did this work for you? Are you planning on closing this question?

--Steve
0
 
LVL 5

Expert Comment

by:vemul
ID: 7669700
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- points to sdussinger
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

vemul
Cleanup Volunteer
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7714875
Per recommendation, force-accepted.

Netminder
EE Admin
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
starter POM and spring-boot-starter,  spring-boot-web 2 58
couple of eclipse 5 38
java stored proc example 9 32
Java Restore security prompts not working 10 16
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question