This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Make css class "private"

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

For example you are independent developer who created a custom component "BaseComponent" that contains only AnchorPane with an empty css class "external".

I'm another developer who created my custom component "SuperComponent", that contains  2 BaseComponent's "One" , "Two", with classes "background" , and "foreground". A SuperComponent.css style class looks like:

And as you can see , i used a "background" class name, that's very common.

A third employee inserts SuperComponent to his big project. And he has already defined css class

Because SuperComponent has only empty class "background" it applies a red background to it, that wasn't expected to.
So how can i encapsulate SuperComponent .background class of being overriten outside?

I'v tried to add another class for each component "One" and "Two", and make css like :

That not helped. A third employee css

overrides it again.

I'v tried to set a root class of my SuperComponent and make css like:  


Also not helped.

I'v found only 2 ways of doing that, non of them i liked:
1) Rename my background class to  "supercomponent-background", but this is nonsense, because for my point i'm already in supercomponent.css and operating my "unique" .background class
2) Override all properties for .background class. This is also meaningless, because i need to overrite EVERY -fx-property.

Please explain how to properly get out of the situation.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!