Adding ScrollBars to JPanel

Posted on 2003-03-31
Medium Priority
Last Modified: 2006-11-17
Hi ,

 I have JFrame, over which i have a JInternalFrame. On this JInternalFrame i am displaying an Image using JPanel, ie JPanel which contains the image is placed on JInternalFrame.

Code is like this.

class myclass extends JPanel{
// constructor
-- --
JScrollPane scroll = new JScrollPane(this);


i have set the color of scrollpane to white(for testing the presence)

When the image is displayed the scrollpane appears as a bar next to image,
when the image is zoomed, this bar disappears and the image is zoomed, but no scrollbars appear.

can i get help for this,

Question by:alpjose
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 92

Accepted Solution

objects earned 120 total points
ID: 8243238
You need to set the preferred size of your panel.
override getPreferredSize() method to return appropriate sizxe.

Author Comment

ID: 8268689
After setting the preferredSize it works,
thank you very much.


Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month9 days, 1 hour left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question