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

Converting EGLImageKHR to greyscale

opengl-es opengl-es-2.0

I'm creating an EGLImageKHR image like this :

CSS: background-color only inside the margin

html css margin background-color

I have searched for an answer but couldn't find it anywhere. My question is reasonably simple: I have a background color of my body, then a large margin, and now I want a different background color

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.