Link to home
Start Free TrialLog in
Avatar of tblackwe
tblackwe

asked on

Using JScrollPanes

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?
Avatar of stalefish
stalefish

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
hi,
 try this

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

mb...
Stalefish has it, you have to explicit them if you want to view them...
ASKER CERTIFIED SOLUTION
Avatar of AlexJ030200
AlexJ030200

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial