TK-UI provides multiple CSS Engine implementations in order to apply CSS styles on different objects, such as Swing components , SWT widgets and even XML elements . Here are some higlights of the TkUI CSS engine:
Label { color:red; } Text { background-color:green; }
Display display = new Display(); // Create SWT CSS Engine CSSEngine engine = new CSSSWTEngineImpl(display); // Parse style sheet engine.parseStyleSheet(new StringReader( "Label {color:red;} Text {background-color:green;}")); /*--- Start UI SWT ---*/ Shell shell = new Shell(display, SWT.SHELL_TRIM); FillLayout layout = new FillLayout(); shell.setLayout(layout); Composite panel1 = new Composite(shell, SWT.NONE); panel1.setLayout(new FillLayout()); // Label Label label1 = new Label(panel1, SWT.NONE); label1.setText("Label 0"); // Text Text text1 = new Text(panel1, SWT.NONE); text1.setText("bla bla bla..."); /*--- End UI SWT ---*/ // Apply Styles engine.applyStyles(shell, true); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose();
For more details, you may consult the SWT/CSS Engine section.
JLabel { color:red; } JTextField { background-color:green; }
// Create Swing CSS Engine CSSEngine engine = new CSSSwingEngineImpl(); // Parse style sheet engine.parseStyleSheet(new StringReader( "JLabel {color:red;} JTextField {background-color:green;}")); /*--- Start UI Swing ---*/ JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); frame.getContentPane().add(panel); // Label JLabel label1 = new JLabel(); label1.setText("Label 0"); panel.add(label1); // Text JTextField text1 = new JTextField(); text1.setText("bla bla bla..."); panel.add(text1); /*--- End UI Swing ---*/ // Apply Styles engine.applyStyles(frame, true); frame.pack(); frame.setVisible(true);
For more details, you may consult the Swing/CSS Engine section.
Background :
CSS version | Property | Swing | SWT | Description |
---|---|---|---|---|
CSS1 | background | Yes | Yes | |
CSS1 | background-attachment | No | No | |
CSS1 | background-color | Yes | Yes | You can use gradient to manage gradient colors. |
CSS1 | background-image | Yes | Yes | |
CSS1 | background-position | No | No | |
CSS1 | background-repeat | No | No |
Border : TODO
Classification :
CSS version | Property | Swing | SWT | Description |
---|---|---|---|---|
CSS1 | clear | No | No | |
CSS2 | cursor | Yes | Yes | |
CSS1 | display | No | No | |
CSS1 | float | No | No | |
CSS2 | position | No | No | |
CSS2 | visibility | Yes | Yes |
Dimension : TODO
Font :
CSS version | Property | Swing | SWT | Description |
---|---|---|---|---|
CSS1 | font | Yes | Yes | |
CSS1 | font-family | Yes | Yes | |
CSS1 | font-size | Yes | Yes | |
CSS2 | font-size-adjust | No | No | |
CSS2 | font-stretch | No | No | |
CSS1 | font-style | Yes | Yes | |
CSS1 | font-variant | No | No | |
CSS1 | font-weight | Yes | Yes | Only normal and bold supported. |
Generated Content : TODO
List and Marker : TODO
Margin : TODO
Outlines : TODO
Padding : TODO
Positioning : TODO
Table : TODO
Text :
CSS version | Property | Swing | SWT | Description |
---|---|---|---|---|
CSS1 | color | Yes | Yes | |
CSS2 | direction | No | No | |
CSS1 | line-height | No | No | |
CSS1 | letter-spacing | No | No | |
CSS1 | text-align | No | No | |
CSS1 | text-decoration | No | No | |
CSS1 | text-indent | No | No | |
CSS1 | text-shadow | No | No | |
CSS1 | text-transform | Yes | Yes | doesn't work with SWT Text and Swing JTextComponent |
CSS1 | unicode-bidi | No | No | |
CSS1 | white-space | No | No | |
CSS1 | word-spacing | No | No |
Pseudo-classes :
CSS version | Property | Swing | SWT | Description |
---|---|---|---|---|
CSS1 | :active | No | No | |
CSS2 | :focus | Yes | yes | |
CSS1 | :hover | Yes | Yes | |
CSS1 | :link | No | No | |
CSS1 | :visited | No | No | |
CSS2 | :first-child | No | No | |
CSS2 | :lang | No | No |
Pseudo-elements : TODO