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 8113421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:49:28+00:00 2026-06-06T02:49:28+00:00

Can someone work out why my JScrollPane is not working. Perhaps something I may

  • 0

Can someone work out why my JScrollPane is not working. Perhaps something I may have missed. I realize this might be silly without any more context than what I’ve shown but please ask and I shall be happy to provide more.

public ApplicationFrame(String title, int x, int y, int width, int height) {
        // Constructor for the ApplicationFrame, no implicit Construc.
        setTitle(title);
        setResizable(true);
        setBounds(x, y, width, height);
                    setLayout(new BorderLayout());
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setIconImage(new ImageIcon(getClass().getResource("resources/topLeft.png")).getImage());
        topMostMenuBar = new TopMenuBar(this);
        setJMenuBar(topMostMenuBar.getMyJMenuBar());
        paneEdge = BorderFactory.createLineBorder(Color.gray);
        blackline = BorderFactory.createLineBorder(Color.black);
        this.frameContent = new ApplicationPanel() {
            //@Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(TI, 0, 0, null);
            }
        };
        mainImageScrollPane = new JScrollPane(frameContent);
        statusPanel = new ApplicationPanel(new Color(0xfff0f0f0));
        leftPanel = new ApplicationPanel(new Color(0xfff0f0f0));
        testPanel = new ColorPanel(new Color(0xfff0f0f0));
        testPanel.setPreferredSize(new Dimension(50,300));
        add(mainImageScrollPane, BorderLayout.CENTER );
        add(statusPanel, BorderLayout.SOUTH);
        add(leftPanel, BorderLayout.WEST);
        Container visibleArea = getContentPane();
        visibleArea.add(frameContent);
        setVisible(true);
        do {
            loadImageIn();
        } while (!initLoadSuccess);
        initButtons();
        leftPanel.add(testPanel, BorderLayout.SOUTH);
    } // end Constructor **

This is a big piece of code so I’m not sure how to make an SSCCE out of it. What youre looking at is the constructor to my subclass of a JFrame, which holds 3 panels. The ApplicationPanel is at this point just a JPanel. The loadImageIn() method opens a filechooser and then loads the chosen image which is painted onto frameContent. The image displays fine, everything works, except when I resize the window, there are no scrollbars.

  • 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-06-06T02:49:29+00:00Added an answer on June 6, 2026 at 2:49 am

    You have this line, which adds the ApplicationPanel to the visibleArea…

    visibleArea.add(frameContent);
    

    Maybe you actually mean this, which adds the JScrollPane to the visibleArea (and the JScrollPane already contains the ApplicationPanel)…

    visibleArea.add(mainImageScrollPane);
    

    When you call new JScrollPane(frameContent), it doesn’t do anything to the panel inside it, it just adds a wrapper around the outside. So, if you want the ability to scroll, you need to refer to the JScrollPane wrapper, rather than the panel itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone help me work out just what I happening here. I have an
I have a working generated SQL query, however I can't work out how I
Can someone help me figuring out why the following jQuery code doesn't work? I
Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object
Can someone explain why this code doesn't work? Intent i = new Intent(this.context, SomeClass.class);
Can someone explain why this doesn't work? int main() { float* x; float a,
Can someone please tell me why this doesn't work? I'm trying to show and
Can someone tell me please why the following example work in Firefox but not
Can someone explain to me why this doesn't work? I've read lots of posts
I was wondering if someone could work this one out as I've been trying

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.