[4469] in java-interest
Re: Alterning a list by removing scroll bar/s
daemon@ATHENA.MIT.EDU (Neil Bartlett)
Sun Dec 31 13:42:20 1995
Date: Sun, 31 Dec 1995 12:25:04 -0500
To: jug@solect.com
From: Neil Bartlett <neilb@the-wire.com>
Cc: java-interest@java.sun.com
At 04:38 PM 12/30/95 PST, you wrote:
>
>For a while now I've been looking around for a way to remove a scroll bar
>from a TextArea object. The closest I've been able to come was in the API
>documentation while trying to research peers. The addNotify() method
>specifically states:
>
> "The peer allows us to modify the TextArea appearance without changing
>its functionality. "
>
>And this is what I want to do ... change the TextArea appearance (by taking
>away a scroll bar). I've tried to research this peer thing, but to no avail.
>There seems to be no documentation on it. Maybe I'm barking up the wrong
>tree here. I looked peer up in the dictionary and it's something that's the
>same rank or standing, something that's legally equal ... that helps a lot!
>:)
I'm afraid you are barking up the wrong tree. The interfaces to the peer
class are the only thing that can be manipulated via a JDK/Java interface.
If the awt/peer/Text[Area|Field|Component]Peer.java class does not contain
the manipulation you want you are out of luck.
Out of interest I have written up a short note of what a peer is. You can
read the note at the Toronto JUG site
www.solect.com/~jug/
>
>Something else which appeared could point me in the right direction was the
>java programming tutorial. There's a section about writing custon components
>(my idea of a custom component being a TextArea without a horizontal scroll
>bar) ... but the section hasn't been written yet. *:-\
>Maybe I need to use another toolkit if that's possible. If this is so, are
>there any other useful toolkits out there, and how would I use another? I'm
>assuming I can use a different toolkit since there's a method in the
>java.awt.toolkit class named getDefaultToolkit() to return the original
>toolkit.
The toolkit is another name for the interface to the operating system/peer
code. Getting the default toolkit is equivalent to gettting hold of a handle
to some code (the Toolkit class) that will give access to operting system
dependent information such as screen size etc.
From this you might gather that writing a toolkit is a very large
undertaking :-)
>Can anyone help me out with an example of a customized component, or maybe
>tookit info, or maybe even some information on removing a scroll bar from a
>list if it's been done elsewhere.
Well you probably write custom components every day in Java - anything you
extend from any of the standard Component/Containers is in effect a custom
component. Writing components using peers et al is obviously possible but is
probably the least desirable way esp. considering the maintence/op sys
porting overhead you would be letting yourself in for.
It is a piece of work but you can write a replacement for the TextArea
component by deriving from Canvas, using drawString to put the text on the
Canvas, and using the Event stuff to detect keyboard input and change the
string. Given the effort of all the other techniques this is by far the
easiest route. If you need help on this contact me directly.
Writing this code would allow you all sorts of freedoms not yet provided by
the TextArea code - colours, mix font sizes, etc. Since I gather your
company's presentation is very important, this could make this route even
more attractive.
Out of interest, why do you want to remove the scrollbars? Maybe if you are
just wanting to display a body of static text to the use, you should
consider using a Label component. Label components support multi-line.
Neil Bartlett
Co-author of upcoming book, The Java Explorer
neilb@the-wire.com 416-769-1851
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com