JScrollPanes scrollbars not showing up

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

Answers


You can either user not JPanel with image but usual JLabel with the image

or

call setPreferredSize() for the panels to reflect the image's size.


Need Your Help

Is there a way to make a custom ios project template only arc?

ios xcode

I am build a custom template that has additional files from another project that was built with ARC. I want to make ARC default to yes and disable it from being toggled off.

Adding REST to Django

python django apache rest

I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy.