🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Scrollbar on Left

#9199
From: Joe Dorman
Date: Thu, 11 May 2000 00:00
142 lines
4810 bytes
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???

JoeD

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.UIManager;

public class Application1 {
   boolean packFrame = false;

   // Construct the application
   public Application1() {
      Frame1 frame = new Frame1();
      // Validate frames that have preset sizes
      // Pack frames that have useful preferred size info, e.g. from their
layout
      if (packFrame) {
         frame.pack();
      }
      else {
         frame.validate();
      }
      frame.setVisible(true);
   }

   // Main method
   public static void main(String[] args) {
      try {

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      }
      catch(Exception e) {
         e.printStackTrace();
      }
      new Application1();
   }

   class LeftScrollPaneLayout extends ScrollPaneLayout {

       public void layoutContainer(Container parent)
       {
          super.layoutContainer(parent);
       }
   }

   class Frame1 extends JFrame {
      JPanel contentPane;
      BorderLayout borderLayout1 = new BorderLayout();
      JPanel jPanel1 = new JPanel();
      JScrollPane jScrollPane1 = new JScrollPane();
      BorderLayout borderLayout2 = new BorderLayout();
      JTextArea jTextArea1 = new JTextArea();

      // Construct the frame
      public Frame1() {
         enableEvents(AWTEvent.WINDOW_EVENT_MASK);
         try {
            jbInit();
         }
         catch(Exception e) {
            e.printStackTrace();
         }
      }

      // Component initialization
      private void jbInit() throws Exception  {
         contentPane = (JPanel) this.getContentPane();
         contentPane.setLayout(borderLayout1);
         this.setSize(new Dimension(400, 300));
         this.setTitle("Frame Title");
         jPanel1.setLayout(borderLayout2);
         jTextArea1.setLineWrap(true);
         jTextArea1.setText("Now is the time for all good men to come to the
aid of their country. " +
       " Now is the time for all good men to come to the aid of their
country. " +
       " Now is the time for all good men to come to the aid of their
country. " +
       " Now is the time for all good men to come to the aid of their
country. " +
       " ");
         contentPane.add(jPanel1, BorderLayout.CENTER);
         jPanel1.add(jScrollPane1, BorderLayout.CENTER);

        // Set the layout to the new ScrollPaneLayout
         jScrollPane1.setLayout(new LeftScrollPaneLayout());
         jScrollPane1.getViewport().add(jTextArea1, null);
      }

      // Overridden so we can exit when window is closed
      protected void processWindowEvent(WindowEvent e) {
         super.processWindowEvent(e);
         if (e.getID() == WindowEvent.WINDOW_CLOSING) {
            System.exit(0);
         }
      }
   }
}

"John P. McGrath" <JPMcGrath@fast.net> wrote in message
news:MPG.1382c8e6dc63b89b989909@forums.borland.com...
> On Tue, 9 May 2000 17:50:25 -0500, Joe Dorman wrote:
>
> > Does anyone have an example of how to move the scrollbar
> > of a JScrollPane to the left side?
>
> I think the best way would be to set the LayoutManager for the
> JScrollPane.  You will want to subclass ScrollPaneLayout, and override
> the layoutContainer() method.
>
> Fond of Athena?
>
> --
> John P. McGrath
> <JPMcGrath@fast.net>
> <jpm@nscs.fast.net>



"John P. McGrath" <JPMcGrath@fast.net> wrote in message
news:MPG.1382c8e6dc63b89b989909@forums.borland.com...
> On Tue, 9 May 2000 17:50:25 -0500, Joe Dorman wrote:
>
> > Does anyone have an example of how to move the scrollbar
> > of a JScrollPane to the left side?
>
> I think the best way would be to set the LayoutManager for the
> JScrollPane.  You will want to subclass ScrollPaneLayout, and override
> the layoutContainer() method.
>
> Fond of Athena?
>
> --
> John P. McGrath
> <JPMcGrath@fast.net>
> <jpm@nscs.fast.net>
Technical Details
Message-ID: <8fetoc$gl2@bornews.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8fa42f$r5d7@bornews.borland.com> <MPG.1382c8e6dc63b89b989909@forums.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: "Joe Dorman" <dorman@texoma.net>
Subject: Re: Scrollbar on Left
Date: 2000/05/11
Message-ID: <8fetoc$gl2@bornews.borland.com>
X-Deja-AN: 622218107
References: <8fa42f$r5d7@bornews.borland.com> <MPG.1382c8e6dc63b89b989909@forums.borland.com>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Organization: Another Netscape Collabra Server User
X-MSMail-Priority: Normal
Newsgroups: borland.public.jbuilder.java.swing