Gidday,
I have done the following:-
1) Created a JFrame
2) Created a JScrollPane
3) Added a large panel to the JScrollPane
4) Added the JScrollPane to the JFrame
The scrollbars appear but don't scroll to see the
large panel. The code is below:-
import javax.swing.*;
import java.awt.*;
public class Trial1{
public static void main(
String args[]){
JFrame f1 = new JFrame();
f1.setTitle("Trial1");
JScrollPane sP = new JScrollPane(new P1(), JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
sP.setPreferredSize(new Dimension(300,200));
f1.getContentPane().add(sP);
f1.setBounds(25,25,400,300);
f1.setVisible(true);
}
}
class P1 extends JPanel{
P1(){
setSize(600,400);
}
public void paintComponent(Graphics g){
super.paintComponent(g);
g.fillRect(25,25,500,350);
}
}
Any help would be much appreciated,
Thanks,