Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3323870
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:21:14+00:00 2026-05-17T23:21:14+00:00

I have a class which extends JScrollPane, its viewport is another class which extends

  • 0

I have a class which extends JScrollPane, its viewport is another class which extends JComponent and implements Scrollable. When the size of the component changes the JscrollBars do not update unless I call revalidate() however this resets the position of the scroll bars to the top left. Is there a way of updating the size of the scroll bars while maintaining their current position?

Thanks, Rob

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:21:15+00:00Added an answer on May 17, 2026 at 11:21 pm

    Is the problem your custom scroll pane or your custom component? We can’t begin to guess what kind of changes you may have made. Post your SSCCE that demonstrates the problem.

    It works fine for me.

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class ScrollSSCCE extends JPanel
    {
        public ScrollSSCCE()
        {
            setLayout( new BorderLayout() );
    
            final JPanel panel = new JPanel();
            panel.setPreferredSize( new Dimension(200, 200) );
            JScrollPane scrollPane = new JScrollPane( panel );
            add( scrollPane );
    
            JButton button = new JButton("Adjust");
            add(button, BorderLayout.SOUTH);
            button.addActionListener( new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    Dimension d = panel.getPreferredSize();
                    d.width +=50;
                    d.height +=50;
                    panel.setPreferredSize(d);
                    panel.revalidate();
                }
            });
        }
    
        private static void createAndShowUI()
        {
            JFrame frame = new JFrame("ScrollSSCCE");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add( new ScrollSSCCE() );
            frame.setSize(150, 150);
            frame.setLocationRelativeTo( null );
            frame.setVisible( true );
        }
    
        public static void main(String[] args)
        {
            EventQueue.invokeLater(new Runnable()
            {
                public void run()
                {
                    createAndShowUI();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Java classes: B, which extends another class A, as follows :
I have a class which implements UserControl. In .NET 2005, a Dispose method is
I have a class which extends UIComponent and draws directly onto a Sprite contained
I have a class which extends a SWC , in the swc i have
I have a class which extends AsyncTask, which is intended to serve as a
I have a DatabaseHelper class which extends SQLiteOpenHelper, what is a good practice to
I have a class A which extends Activity. From the class A ,I am
I have a class CircularBuffer which extends AbstractList. I have a second class ExponentialUnrolledLinkedList
I have class JLabelExtended, which extends class javax.swing.JLabel. I extend it, because I want
I have a class which I'm serialising to send over a unix socket and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.