I'm trying to create a custom Look-And-Feel using the Synth-Framework.
I successfully used a tutorial ( Look-And-Feel Tutorial by Oracle/Sun ) to experiment,and managed to skin Buttons, Panels etc.
The problem i have now is,that i want to decorate the Window/JFrame.
I read some things about it and tried it out with the MetalLookAndFeel and this Code,that works:
try{
UIManager.setLookAndFeel(new MetalLookAndFeel());
}catch(UnsupportedLookAndFeelException e){
}
javax.swing.JFrame.setDefaultLookAndFeelDecorated(true);
new SFframe().setVisible(true);
Now i try to use my own LAF:
<?xml version="1.0" encoding="UTF-8"?>
<synth>
<!-- Style that all regions will use -->
<style id="backingStyle">
<opaque value="TRUE"/>
<font name="Dialog" size="14"/>
<state>
<color value="#04688D" type="BACKGROUND"/>
<color value="#FFFFFF" type="FOREGROUND"/>
</state>
<defaultsProperty key="Synthetica.window.decoration" type="boolean" value="true"/>
</style>
<bind style="backingStyle" type="region" key=".*"/>
<style id="button">
<!-- Shift the text one pixel when pressed -->
<property key="Button.textShiftOffset" type="integer" value="1"/>
<!-- set size of buttons -->
<insets top="4" left="4" bottom="4" right="4"/>
<state>
<imagePainter method="buttonBackground" path="/synth/images/Button.png" sourceInsets="4 4 4 4"/>
<font name="Dialog" size="16"/>
<color type="TEXT_FOREGROUND" value="#FFFFFF"/>
</state>
<state value="PRESSED">
<imagePainter method="buttonBackground" path="/synth/images/Button_pressed.png" sourceInsets="4 4 4 4"/>
</state>
<state value="MOUSE_OVER">
<imagePainter method="buttonBackground" path="/synth/images/Button_over.png" sourceInsets="4 4 4 4"/>
</state>
</style>
<bind style="button" type="region" key="Button"/>
</synth>
The code i use to load the LAF looks like this:
SynthLookAndFeel laf = new SynthLookAndFeel();
try{
InputStream in = SFframe.class.getResourceAsStream("/synth/synth.xml");
laf.load(in, SFframe.class);
UIManager.setLookAndFeel(laf);
}catch(ParseException | UnsupportedLookAndFeelException e){
e.printStackTrace();
}
javax.swing.JFrame.setDefaultLookAndFeelDecorated(true);
new SFframe().setVisible(true);
The Buttons and Panels get skinned, but of course, the Window/JFrame doesn't.
I just can't find a source on how to skin/decorate a Window/JFrame with Synth-XML. Can someone help me there?