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


Groups > comp.lang.java.gui > #4681

Re: adding border to JSlider using Nimbus

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From Tom <tom400f@gmail.com>
Newsgroups comp.lang.java.gui
Subject Re: adding border to JSlider using Nimbus
Date Thu, 8 Sep 2011 22:57:42 +0000 (UTC)
Organization Aioe.org NNTP Server
Lines 38
Message-ID <pan.2011.09.08.22.57.39@gmail.com> (permalink)
References <daabdcd3-7d35-400f-9235-edf9539fef75@t30g2000prm.googlegroups.com>
NNTP-Posting-Host Vd3zjYYo2heJAT9ZVcrkiA.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
X-Complaints-To abuse@aioe.org
User-Agent Pan/0.133 (House of Butterflies)
X-Notice Filtered by postfilter v. 0.8.2
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:4681

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar


Thread

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