Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Attaching Scrollbars to Containers  RSS feed

 
Dev Prakash
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can ScrollBar be Attached to Containers like Applet, frame etc.
I have a big user registration Applet and I want to make it small size and attach the scroll bar so that users can scroll and fill up the data. Please help me,How can I acieve this?
- Dev Prakash
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get better help here.
Ajith
[This message has been edited by Ajith Kallambella (edited October 18, 2000).]
 
prasanth Tata
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dev Prakash,

/* Declares JScrollPane reference scroller and initializes with a
new JScrollPane object. */
JScrollPane scroller = new JScrollPane (outputArea);
scroller.setBackground(Color.pink);
scroller.setForeground(Color.magenta);
/* Get the applet's GUI component display area and attaches the
scroller to the Container c. */
Container c = getContentPane();
c.add(scroller);
 
prasanth Tata
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi dev prakash,
Sorry previous message was incomplete.
You can use JScrollPane class to solve your problem.
Follow this code :-
JTextArea outputArea = new JTextArea(10,20);
/* Declares JScrollPane reference scroller and initializes with a
new JScrollPane object. */
JScrollPane scroller = new JScrollPane (outputArea);
scroller.setBackground(Color.pink);
scroller.setForeground(Color.magenta);
/* Get the applet's GUI component display area and attaches the
scroller to the Container c. */
Container c = getContentPane();
c.add(scroller);
May be it helps you !
Take care
Prasanth Tata
 
Dev Prakash
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Prasanth Tata,
This solutions works, but I wanted to just work with AWT Components and not Swing.
I can attach a panel to applet and scrollpane to panel and all other components to scrollpane. And it works fine, BUT I wanna know if we can directly attach scroll bar to applet.
-Dev Prakash
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!