Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #4681
| From | Tom <tom400f@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.gui |
| Subject | Re: adding border to JSlider using Nimbus |
| Date | 2011-09-08 22:57 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <pan.2011.09.08.22.57.39@gmail.com> (permalink) |
| References | <daabdcd3-7d35-400f-9235-edf9539fef75@t30g2000prm.googlegroups.com> |
On Thu, 08 Sep 2011 11:57:31 -0700, Fred wrote: > I create a vertical JSlider with ticks and labels painted. Its width is > x pixels (x depends on the font, etc.) > > I then add a border using: > mySlider.setBorder( BorderFactory.createLineBorder( Color.black, > 10 ) ); > > With Metal L&F, the internal part ofstays the same width, with a > 10-pixel wide border around it; the component's width is now (x+20) > pixels. This is what I would expect - the component wants to be x pixels > wide (to display the slider and the scales) plus 10 pixelsl on each side > for the border. > > Using Nimbus, however, the component stays the same width, with the > border inside it, clipping 10 pixels off each edge. > > How can I add the border correctly using Nimbus? > > Here's the code: > -- snip -- A L&F may use use borders as part of what it does to paint the component. This is not unique to Nimbus - I think you get some interesting effects putting borders directly on to text fields in Windows... Two things to try: See if the component already has a border with JComponent.getBorder(). If it does, replace it with a CompoundBorder putting the existing one as the inside and yours as the outside. Or Put the slider inside a JPanel as the only component and put your border on that.
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
adding border to JSlider using Nimbus Fred <fred.l.kleinschmidt@boeing.com> - 2011-09-08 11:57 -0700
Re: adding border to JSlider using Nimbus Tom <tom400f@gmail.com> - 2011-09-08 22:57 +0000
Re: adding border to JSlider using Nimbus "John B. Matthews" <nospam@nospam.invalid> - 2011-09-08 19:09 -0400
Re: adding border to JSlider using Nimbus Roedy Green <see_website@mindprod.com.invalid> - 2011-09-16 16:45 -0700
Re: adding border to JSlider using Nimbus "John B. Matthews" <nospam@nospam.invalid> - 2011-09-16 23:19 -0400
csiph-web