how to introduce CSS style for various swing components like JButton,Jpanel etc. in a swing application?
+2
A:
You don't. The HTML parser that some Swing components use does not even support most HTML tags; it does not support CSS at all.
If you need advanced HTML support in a Java app, you will have to use one of the third-party components that provide it.
Michael Borgwardt
2009-06-29 08:26:22
This is inaccurate. In my experience, using a <style> element in a <head> element after your <html> opening, you can put CSS rules. Note, however, that Swing support is CSS 1.0 at most - it looks like background will work, but overflow won't (which is quite a shame in my case...).
splintor
2009-11-23 19:15:42
+2
A:
You can use the various Swing properties to describe UI defaults that will be shared by all components - like fonts etc - but as Michael mentions; there's no way to do full CSS
. For example:
FontUIResource f = new FontUIResource("Tahoma", Font.BOLD, 12)
UIManager.put("MenuBar.font", f); //javax.swing.UIManager
UIManager.put("Menu.font", f);
UIManager.put("RootPane.titleFont", f);
oxbow_lakes
2009-06-29 08:53:41
I've been using its predecessor from the now defunct JAXX. Using css is a great way to separate out presentation details from your Java code, and the implementation is pretty good.
Geoffrey Zheng
2010-09-19 04:40:07
+1
A:
Like this --> http://today.java.net/article/2003/10/05/swing-and-css
Achi Furtan
2010-07-23 14:44:13