adding scroll panes

hi friends i want to add a scroll pane to my frame, i have tried adding it but the scrollbars on the scroll pane remain disabled even though the content on the scroll pane is beyond visible area , and i am able to scroll down with the mouse roler but not through scrollbars. can you please help me out with some example code or something.

thx

[355 byte] By [suhail_anwar_khana] at [2007-10-3 9:10:25]
# 1
Post a Short,Self Contained, Compilable and Executable, Example Program of your problem.
zadoka at 2007-7-15 4:22:26 > top of Java-index,Desktop,Core GUI APIs...
# 2

here is the sample application+++++++>

import java.awt.*;

import javax.swing.*;

public class sp extends Frame

{

JScrollPane sp1;

sp()

{setTitle("in constructor");

setLayout(null);

setLocation(50,50);

setVisible(true);

setSize(500,500);

TextArea ta=new TextArea();

ta.setLocation(0,0);

ta.setSize(130,120);

ta.setVisible(true);

ta.setText("some\n text \n in text area");

int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS ;

int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;

sp1=new JScrollPane(ta,v,h);

// sp1.setLayout(null);

sp1.setLocation(20,100);

sp1.setSize(200,200);

sp1.setVisible(true);

add(sp1);

Color bluec=new Color(0,0,255);

sp1.setBackground(bluec);

bluec=new Color(233,233,0);

setBackground(bluec);

}

public static void main(String args[])

{

sp sp11=new sp();

}

}

suhail_anwar_khana at 2007-7-15 4:22:26 > top of Java-index,Desktop,Core GUI APIs...
# 3
You are mixing Swing and AWT. You need to stick with one or the other because it is not good to mix heavy and light-weight components.I would suggest using only Swing, but the decision is up to you.
zadoka at 2007-7-15 4:22:26 > top of Java-index,Desktop,Core GUI APIs...
# 4
what should i do if i want to add a scrollable pane to my AWT frame?
suhail_anwar_khana at 2007-7-15 4:22:26 > top of Java-index,Desktop,Core GUI APIs...
# 5
Use ScrollPane instead of JScrollPane.
zadoka at 2007-7-15 4:22:26 > top of Java-index,Desktop,Core GUI APIs...
# 6
ok thanks
suhail_anwar_khana at 2007-7-15 4:22:26 > top of Java-index,Desktop,Core GUI APIs...