Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using JScrollPanes

Posted on 2000-03-09
4
Medium Priority
?
286 Views
Last Modified: 2012-05-05
Check out the code below and see if you can tell me why my windows don't show the ScrollPane the way it's supposed to:

Border compound = BorderFactory.createEmptyBorder(0,10,10,10);

ev = new EventView(jDateTree, top, thisDateHash);  // returns a JPanel
jEvent Panel = new JPanel();
jEventPanel.setBounds(0,0,780,getHeight());
jEventPanel.setLayout(null);

ev.setLayout(null);
ev.setBounds(170,30,500,getHeight()-30);
ev.setBorder(compound);

JScrollPane evScrollPane = new JScrollPane(ev);

JEventPanel.setPrefferredSize(new Dimension(getWidth() - 170, getHeight() - 30));
evScrollPane.setBounds(170,30,1000,getHeight()-30);
jEventPanel.add(evScrollPane);
JEventPanel.setBorder(compound);


My applet compiles and runs fine. It shows what it is supposed to, but there is only one scrollbar at the bottom of the applet.  This should be a simple task, yet I don't know why it's not working.  Could someone please help!!!????The element that is supposed to be scrolled is a JPanel, and I know it's legal to have a JPanel inside a scroll pane right?
0
Comment
Question by:tblackwe
[X]
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
4 Comments
 
LVL 2

Expert Comment

by:stalefish
ID: 2602736
I believe by default that the scrollbars in scrollpane are only shown when necessary. If you want them to be visible always, you have to explicitly tell it that by using

JScrollpane.setVerticalScrollBarPolicy(int policy);
and
JScrollPane.setHorizontalScrollBarPolicy(int policy);

Dustin
0
 
LVL 6

Expert Comment

by:expertmb
ID: 2604311
hi,
 try this

     evScrollPane.getViewport().add(parameter, null);
     parameter = e.g., list,table

mb...
0
 
LVL 1

Expert Comment

by:David MacDonald
ID: 2605663
Stalefish has it, you have to explicit them if you want to view them...
0
 
LVL 2

Accepted Solution

by:
AlexJ030200 earned 200 total points
ID: 2617993
It would be a good idea if you call
ev.revalidate();
after changing sizes.

From the java tutorial:

"Changing the size of a scroll pane's client is a two-step process. First, set the client's preferred size. Then, call revalidate on the client to let the scroll pane know that it should update itself and its scroll bars."


hope this helps.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

636 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