cyberbeat / java-css Goto Github PK
View Code? Open in Web Editor NEWStyling Java Swing GUIs with CSS
License: GNU General Public License v2.0
Styling Java Swing GUIs with CSS
License: GNU General Public License v2.0
This is a modified version of JAVA-CSS, which was originally found here: http://java.net/projects/javacss/ Java-CSS is about styling swing GUIs with CSS-like stylesheets. It works quite well, and can be combined with layoutmanagers like miglayout for example. It was introduced here http://weblogs.java.net/blog/2008/07/17/introducing-java-css by Ethan Nicholas. I removed javafx-support and fixed a memory leak. Link above on archive.org: https://web.archive.org/web/20150512202732/http://weblogs.java.net/blog/2008/07/17/introducing-java-css Example from above page: Before: JSlider slider = new JSlider(0, 100, currentValue); slider.setMinorTickSpacing(5); slider.setMajorTickSpacing(25); slider.setPaintTicks(true); slider.setForeground(DEFAULT_FOREGROUND); With CSS: * { font: Dialog-12; foreground: black; } JSlider#mySlider { minorTickSpacing: 5; majorTickSpacing: 25; paintTicks: true; } JSlider#tip:{value <= 10} { background: red !over 0.3s; } Admittedly, in this simple example there's not a clear benefit to using CSS instead of a proprietary file -- the syntax is a bit different, but the two files are about equally complex. The real benefit of CSS comes from all of the additional power it offers. Want to only affect sliders which appear under MyColorChooser? No problem, use the selector "MyColorChooser JSlider". Or pick every label serving as a title with "JLabel.title". What about JButtons, but only when they are moused over? Use "JButton:mouseover". What about even more complex selectors, such as "JSliders which are direct children of a MyPanel appearing in the currently active window, but only when they are set to their maximum value"? No problem, with a slight syntax extension "Window:active MyPanel > JSlider:{value == maximum}" does just the trick. The stylesheet specifies some interesting rules, such as JSlider#tip:{value <= 10} { background: red !over 0.3s; } The JSlider#tip portion of the selector means that this rule only applies to the JSlider named "tip". Okay, simple enough. The next part ":{value <= 10}" is what is called a programmatic pseudoclass -- basically just a boolean expression which controls whether or not the rule applies, taking the form of an EL expression evaluated using Beans Binding. So this rule applies only when the slider has a value of 10 or les
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.