Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes SCROLLBAR ADDED BUT NOT WORKING IN TEXTAREA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "SCROLLBAR ADDED BUT NOT WORKING IN TEXTAREA" Watch "SCROLLBAR ADDED BUT NOT WORKING IN TEXTAREA" New topic
Author

SCROLLBAR ADDED BUT NOT WORKING IN TEXTAREA

Indu Anand
Greenhorn

Joined: Jan 06, 2013
Posts: 7
HELLO! I WANT TO ADD A SCROLLBAR IN TEXTAREA USING JAVA SWING ,IT IS SHOWN BUT NOT ENABLED.......PLEASE TELL ME THE WHOLE CODE TO ENABLE MY SCROLLBAR..
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
java is case-sensative.

you need a keyboard that is able to type
lower-case characters.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1085
    
  10

Hi Indu,
Welcome to the Ranch!

You can checkout the tutorial that provides lot of information and examples for text components.

Also, please do not type in all caps. It is considered as 'shouting' on the internet and will put away people who are willing to help you.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Indu Anand
Greenhorn

Joined: Jan 06, 2013
Posts: 7
i have searched a lot on internet..but after creating a scrollbar..i am unable to enable this....can anybody give me a proper process & coding to do this.



my code is:-
JTextArea t1=new JTextArea();
t1.setEditable(false);

JScrollPane spn=new JScrollPane(t1);
spn.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

t1.setLineWrap(true);
f.add(t1);
f.add(spn);



now what more i need to do....if i need any kind of listener??? scrollbar is shown, but it is shown disable.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39396
    
  28
If yo had looked at the link you were given, you would have seen a tutorial link about using scroll panes. That has examples of what you want in.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> now what more i need to do.... scrollbar is shown, but it is shown disable.

the basics are that what is in the scrollpane/viewport must have a preferredSize larger than that of the scrollPane/viewport,
otherwise the scrollbar/s have nothing to scroll.

a lot depends on the layoutManager/s used.

if you want a solution, post a demo program so we can see what you're doing
i.e. just a textArea in a scrollPane in a JFrame
Indu Anand
Greenhorn

Joined: Jan 06, 2013
Posts: 7
more suggestions or code???please post a simple code for that....which has a working scrollbar in textarea using java..
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1085
    
  10

In your code, you are adding both textarea and scrollpane to the 'f' variable. Once you create a JScrollPane by passing the text component, it is enough to add the scrollpane instance. There is no need to add both.
Indu Anand
Greenhorn

Joined: Jan 06, 2013
Posts: 7
please explain your answer with proper & simple code....
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> please explain your answer with proper
> & simple code....

you are the one with the problem code.
post your code, or, if you actually have none,
pay someone to write it for you.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1085
    
  10

Indu Anand wrote:please explain your answer with proper & simple code....

You provided some code and I have pointed out where the issue is in that code. Have you tried out my suggestions?
Indu Anand
Greenhorn

Joined: Jan 06, 2013
Posts: 7
yes i have tried your suggestion.....but by not adding scrollpane to frame the scrollpane is not shown,so i have to add this...
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Ranganathan Kaliyur Mannar wrote:In your code, you are adding both textarea and scrollpane to the 'f' variable. Once you create a JScrollPane by passing the text component, it is enough to add the scrollpane instance. There is no need to add both.


Indu Anand wrote:yes i have tried your suggestion.....but by not adding scrollpane to frame the scrollpane is not shown,so i have to add this...


Read the responses more carefully. And have you gone through the recommended tutorial yet?


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SCROLLBAR ADDED BUT NOT WORKING IN TEXTAREA