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

  • Home
  • SEARCH
  • 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 6887705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:55:02+00:00 2026-05-27T05:55:02+00:00

So, I have a grid layout which stores JScrollPane’s in each cell. These are

  • 0

So, I have a grid layout which stores JScrollPane’s in each cell. These are also put into an array for other purposes. The “View” extends “JPanel” so it’s just a regular panel with image support. The application starts up with cell’s filled with scrollPane’s that contain the View which doesn’t have a image yet.

At that point I see no scrollbar, but that doesn’t matter since there is nothing inside the JPanel. As soon as I open an image and use drawImage in the paintComponenet of the JPanel I don’t see scrollbar’s showing up. Here’s how I create the grid and the Scrollpane

private void createContentPane() 
{
        GridLayout gridLay = new GridLayout(GRID_ROWS, GRID_COLUMNS);
        perspectiveTbl = new JScrollPane[NUM_PERSPECTIVE];
        mainPane = new JPanel();
        mainPane.setLayout(gridLay);

        int idx = 0;

        while(idx < perspectiveTbl.length)
        {
            perspectiveTbl[idx] = new JScrollPane(new View(modelImage));
            mainPane.add(perspectiveTbl[idx]);
            idx++;
        }

        this.getContentPane().add(mainPane, BorderLayout.CENTER);
}

I’m not exactly sure why the scrollbar’s aren’t showing up, should they have been set inside the panel for the image?

Here’s an image of the application, as you can see the picture of the shoe does not receive scrollbar’s so there is no way to view the rest of the picture:

Picture

  • 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-27T05:55:02+00:00Added an answer on May 27, 2026 at 5:55 am

    Thanks for the hint Stanislav, I actually figured it out and got it working an hour ago, but you did give the right path to fix it with the preferredSize attribute. I ended up re-implemented getPreferredSize with the size of the image inside the panel, added revalidate to the paint event so that the bars show up as soon as the image is loaded.

    public void paintComponent(Graphics g) 
    {
        super.paintComponent(g);
        g.drawImage(image, 0, 0, null);
        this.getViewScrollPane().revalidate();
    }
    
    public Dimension getPreferredSize() 
    {
        if(image != null)
            return new Dimension(image.getWidth(),image.getHeight());
        else
            return super.getPreferredSize();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a LinearLayout that contains sublayouts which essentially mimick a 3x2 grid. Each
I have a Grid which shows a layout for an invoice. What I would
I made a swing application in which i have a grid layout on a
I have a grid which is dynamically added to the Layout-root which could have
I have a JPanel with a Grid Layout. In the cells of the grid
I have a Panel which hosts a number of child controls in a grid
I have a QCheckbox in a grid layout defined as such: self.isSubfactorCheckbox = QtGui.QCheckBox('Is
I have a Silverlight 3 application the inside of whose grid layout root looks
i have a grid view which contain images when click on one image it
I have a gridview in which there are two elements in each of its

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.