🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9215

Re: Scrollbar on Left

#9215
From: John P. McGrath
Date: Sun, 14 May 2000 00:00
38 lines
1878 bytes
On Thu, 11 May 2000 13:33:19 -0500, Joe Dorman wrote:

> Here's a sample of my attempt to subclass ScrollPaneLayout.
> I can't get it to work.  If I comment out the setLayout call,
> the JTextArea displays the text.  With the setLayout call,
> nothing displays in the JScrollPane.  Any ideas???

I found the problem.  The following is from the JavaDocs for the class 
ScrollPaneLayout:

   public void syncWithScrollPane(JScrollPane sp)

      This method must be called after setting a JScrollPanes
      layout manager. It initializes all of the internal fields
      that are ordinarily set by addLayoutComponent().

      For example:

         ScrollPaneLayout mySPLayout = new ScrollPanelLayout() {
            public void layoutContainer(Container p) {
               super.layoutContainer(p);
               // do some extra work here ...
            }
         };
         scrollpane.setLayout(mySPLayout):
         mySPLayout.syncWithScrollPane(scrollpane);

This is, IMHO, a very bad design.  Since JScrollPane requires that any 
LayoutManager set on it be a subclass of ScrollPaneLayout, it could and 
should call syncWithScrollPane() itself.

I can think of no reason to impose this requirement on the caller.  It 
just invites errors.

-- 
John P. McGrath
<JPMcGrath@fast.net>
<jpm@nscs.fast.net>
Technical Details
Message-ID: <MPG.13892567d776bc77989925@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8fa42f$r5d7@bornews.borland.com> <MPG.1382c8e6dc63b89b989909@forums.borland.com> <8fetoc$gl2@bornews.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,90c0ec9acc6f4a03
X-Google-Attributes: gid111d45,public
From: John P. McGrath <JPMcGrath@fast.net>
Subject: Re: Scrollbar on Left
Date: 2000/05/14
Message-ID: <MPG.13892567d776bc77989925@forums.borland.com>
X-Deja-AN: 623451310
References: <8fa42f$r5d7@bornews.borland.com> <MPG.1382c8e6dc63b89b989909@forums.borland.com> <8fetoc$gl2@bornews.borland.com>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.swing