kirill-grouchnikov / radiance

Building modern, elegant and fast Swing applications
BSD 3-Clause "New" or "Revised" License
794 stars 89 forks source link

Beveled Border on Jbutton #351

Closed DustinMerrell closed 3 years ago

DustinMerrell commented 3 years ago

Version of Radiance 4.0 Snapshot

Sub-project Substance

Version of Java Java 11

Version of OS Windows 10 and Mac 11.4

I am unable to get a beveled border to paint on a Jbutton. Is there any documentation on this that I could be missing?

kirill-grouchnikov commented 3 years ago

How does your code look like? What are the visuals you're aiming to achieve?

DustinMerrell commented 3 years ago

I want to have some sort of border or color change based on the user selection. I am looking to change the hue of the buttons or the border color of the buttons to the user defined color.

void setColor(Color color) {

if (this.color==color) return;

this.color = color;

// if (py3d.crew.Decorator.usingLowUI())

  this.setColor(color);

  this.setOpaque(true);

  setBackgrounds(null, color);

// if (color == null)

// setBorder(originalBorder);

// else{

// setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, color, color));

// setBackgrounds(null, color);

// }

setBorder((color==null) ? originalBorder : BorderFactory.createBevelBorder(BevelBorder.RAISED, color, color));

}

Thank you

Dustin Merrell

Application Systems Director

Pyware Customer Support

Phone - 940-240-8536

Fax - 940-464-0573

Chat with me - https://drift.me/pywaredustin https://drift.me/pywaredustin

http://www.facebook.com/Pygraphics www.facebook.com/Pygraphics

Facebook Pyware Users Group

https://www.facebook.com/groups/377417402308160/ https://www.facebook.com/groups/377417402308160/

From: Kirill Grouchnikov @.> Sent: Friday, July 9, 2021 4:55 PM To: kirill-grouchnikov/radiance @.> Cc: DustinMerrell @.>; Author @.> Subject: Re: [kirill-grouchnikov/radiance] Beveled Border on Jbutton (#351)

How does your code look like? What is the visuals you're aiming to achieve?

— You are receiving this because you authored the thread. Reply to this email directly, https://github.com/kirill-grouchnikov/radiance/issues/351#issuecomment-877475987 view it on GitHub, or https://github.com/notifications/unsubscribe-auth/ACI4VTM3VMTRYPEJBHFW54DTW5V2NANCNFSM5ADPXWTA unsubscribe.

kirill-grouchnikov commented 3 years ago

Using BorderFactory.createBevelBorder directly is not supported, for the simple reason that it doesn't play well with Substance visuals. Since it's still a bit vague in the description, I'll link to a few options:

  1. Using a custom border painter in a custom skin that provides the option to define your own border visuals. Note the skin's border painter is used across different components, the JComponent that you get is not guaranteed to always be a button
  2. Using a custom color scheme bundle with a color scheme registered for BORDER color scheme association kind and one of the selected component states - if that is what you mean by "user selection"
  3. Calling JComponent.setBackground along with SubstanceCortex.GlobalScope.setColorizationFactor API to control application-specific background color that is mixed into the current skin