Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38296

Re: How does a scrollbar paint differently?

Newsgroups comp.lang.java.programmer
Date 2018-05-30 08:24 -0700
References <00f505eb-cb45-4306-a554-bfad87371dd9@googlegroups.com> <7f435fa4-c7c0-4899-a757-f900eaae07f8@googlegroups.com> <pekg11$r62$1@dont-email.me> <21dc0f98-f0b2-44fd-967c-e98563fcbb15@googlegroups.com>
Message-ID <194b2ea5-122d-49f6-b284-9f80fcb2ab62@googlegroups.com> (permalink)
Subject Re: How does a scrollbar paint differently?
From Eric Douglas <e.d.programmer@gmail.com>

Show all headers | View raw


On Wednesday, May 30, 2018 at 10:38:07 AM UTC-4, Eric Douglas wrote:
> On Tuesday, May 29, 2018 at 5:17:35 PM UTC-4, Eric Sosman wrote:
> >      The first scrollbar sounds like the one belonging to the Java cross-
> > platform "Metal" look and feel, javax.swing.plaf.metal.MetalLookAndFeel. 
> >   The other sounds like com.sun.java.swing.plaf.windows.WindowsLookAndFeel
> > (or possibly com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel).
> > Are you *sure* both getLookAndFeel() calls return the latter?  Or, are
> > you *sure* that there's no setLookAndFeel() call after getLookAndFeel()?
> > 
> 
> I definitely only call setLookAndFeel once, where I am assigning the WindowsLookAndFeel.  I just tried creating a raw test program with all Oracle classes, and javax.swing.plaf.metal.MetalLookAndFeel is the default LookAndFeel, and when I assign the WindowsLookAndFeel it looks right.  So now I have to see what my custom classes are doing differently that I was definitely calling the set for the WindowsLookAndFeel but somehow it displayed the scrollbar as MetalLookAndFeel.

I fixed it.
...
My test class has a display method which creates the JFrame, adds the JList, and sets it visible.  This method gets called from the EventQueue.invokeLater.  I had multiple methods which needed to reference the JList/JScrollPane control so I made that a class level variable, but I also called the constructor for that up where I declared it, so it was deciding which scrollbars to display before I set the LookAndFeel.  If I add a setLookAndFeel in that class in a static block, or move the constructor call into the method after the setLookAndFeel it works fine.

Now how to change the scrollbars?  If I call the constructor for the JScrollPane, then call UIManager.setLookAndFeel, then call the JScrollPane's updateUI(), it's still showing the default bars.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How does a scrollbar paint differently? Eric Douglas <e.d.programmer@gmail.com> - 2018-05-29 12:42 -0700
  Re: How does a scrollbar paint differently? Eric Douglas <e.d.programmer@gmail.com> - 2018-05-29 13:50 -0700
    Re: How does a scrollbar paint differently? Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-05-29 17:17 -0400
      Re: How does a scrollbar paint differently? Eric Douglas <e.d.programmer@gmail.com> - 2018-05-30 07:37 -0700
        Re: How does a scrollbar paint differently? Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-05-30 11:09 -0400
          Re: How does a scrollbar paint differently? Eric Douglas <e.d.programmer@gmail.com> - 2018-05-30 08:26 -0700
        Re: How does a scrollbar paint differently? Eric Douglas <e.d.programmer@gmail.com> - 2018-05-30 08:24 -0700
          Re: How does a scrollbar paint differently? Eric Douglas <e.d.programmer@gmail.com> - 2018-05-30 08:46 -0700
            Re: How does a scrollbar paint differently? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-05-30 18:14 +0200
              Re: How does a scrollbar paint differently? Eric Douglas <e.d.programmer@gmail.com> - 2018-05-30 10:31 -0700
                Re: How does a scrollbar paint differently? Eric Douglas <e.d.programmer@gmail.com> - 2018-05-30 10:53 -0700
                Re: How does a scrollbar paint differently? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-05-30 20:35 +0200

csiph-web