Look and Feel in Nuhra is done by CSS.
This is "webish", easy, and state of the art.
if you have doubts about this, cause you know Swing and think this is the best you can image, consider this:
- Have you ever written a LaF for your apps? No? Then you can put your mind at rest. Nuhra also provides some ready to use LaFs.
- Ever had trouble about plattform compatibility and LaFs? With web technology like Nuhra you will never have again :-)
- Ever wondered how someone can create a good LaF insid his Swing app or ever had trouble with mixture of design and content in your Swing classes?
Here is the answer:
So, if I should design LaF for Swing I would use CSS.
Further more, you can change (adapt) the LaF of your application during runtime without having to restart anything (like every well desiged web app to be honest).
So do you have to learn CSS?
- Perhaps you are a web developer, then you likely know CSS already and will love the direct webish Nuhra way.
- Perhaps you don't want to care about LaF and just want to use an existing LaF (like Java does) and love Nuhra for providing web LaFs.
- Perhaps you start with a default LaF and love the conveniant methods in the components which provide basic styling of each component in a Java way.
- Perhaps you want to learn more about modern web technologies and will lobe Nuhra because it's already using them in a professional way.
There are two ways of defining CSS styles:
- inside the application designed to special components
- extern in the style.css which is a file under www/ in Nuhra
There are several levels of CSS used by Nuhra.
As already said, styles are kept out of Java-logic in a separate file.
Here you can find global definitions:
- tag based styles: per HTML tag - very rough
- class based styles: per CSS class for specific situations
How are styles bound to the components you define in you application?
- Every component is printed to HTML-tags. They are automatically bound to the tag based styles by the browser.
- Every component-class has a default css-class. When printed and sent to the browser, the browser will bind the CSS to the printed HTML-component.
So nothing to do for you until now :-)
You interact like this:
- You can change the css-class of every component. Then you have to define an equivalent css class in your style.css. (Hint: You can include your personal style into the LaF-style like this @include mystyleclasses.css).
- You can set styles direct to components (the Java way -not recommended) with the method "addStyle()" in every component.
- You can use the methods for conveniance in every component like "setWidth()", "setHorizontalAlignment()". This methods are only thin wrappes which just write css styles directly into the HTML code.
To understand CSS you have to know that:
CSS is
cascading style sheets, i.e. the style of a component is calculated by the browser considering (in this order):
- the style of the surrounding tag
- the tag style in the style.css
- the tag class(es) in the style.css
- the tag style directly in the tag
Conclusions:
- So every adjustment can be overridden by a subsequent level style.
- A wise hierarchy has to be used (Nuhra does that for you)
- CSS knowledge is not needed but (at least for experienced developers) useful.
As with every web technology Nuhra tries to make best practice usage of it so that you don't have to make every error once again. ;-)