Hi guys i have a problem with JScrollPane,
Firstly i have 2 custom JPanel's i wanted to add them to a JSplitPane
so i added them to a JScrollPane and then those JSplitPane but the problem is if i drag the divider in splitpane the panel doesnot scroll :'(
Here is how i added the panels(LeftPanel and RightPAnel are my custom JPanels)
and (leftpane and rightpane are JScrollPane objects) and splitpane is JSplitPane object
leftpane=new JScrollPane()
JViewport viewport = leftpane.getViewport();
viewport.add(new LeftPanel(us));
viewport.setPreferredSize(new Dimension(500,350));
rightpanel is also same
splitpane=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftpane,rightpane);
splitpane.setOneTouchExpandable(true);
splitpane.setDividerLocation(700);
leftpane.setMinimumSize(new Dimension(500,350));
rightpane.setMinimumSize(new Dimension(250,350));
then i added the splitpane to contentpane and done setBounds for split pane
Here is how the custom panel looks like
class RightPanel extends JPanel
{
CalendarPanel cp;
JLabel contentlabel;
RightPanel()
{
super();
setLayout(null);
cp=new CalendarPanel();
contentlabel=new JLabel("Information about clicked date goes here");
add(cp);
add(contentlabel);
cp.setBounds(10,10,350,200);
contentlabel.setBounds(10,240,350,250);
}
}
both left and right panel's are alike so help with this scrolling hav i done wrong somewhere :?: if there is wrong tell me i always like to get educated :)
But the interesting thing is if i add my panel like this it is scrollable :-O
leftpanel=new JPanel();
leftpanel.add(component1);
.//remaining components
.//same with rightpanel
leftpane=new JScrolPane(leftpanel,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
rightpane=new JScrollPane(rightpanel,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
splitpane=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftpane,rightpane);
than you in advance
-Tizon