Synth-Framework를 사용하여 사용자 정의 Look-And-Feel을 만들려고합니다.Java-LAF : Synth-XML을 사용하여 장식을 만드는 방법은 무엇입니까?
내가 성공적으로 실험을 튜토리얼 (Look-And-Feel Tutorial by Oracle/Sun )를 사용하고, 피부 버튼에 관리 등 패널
나는 창/JFrame의를 장식 할 것인지, 지금이 문제.
나는 그것에 대해 몇 가지를 읽고 작동 MetalLookAndFeel의이 코드, 그것을 밖으로 시도 :try{
UIManager.setLookAndFeel(new MetalLookAndFeel());
}catch(UnsupportedLookAndFeelException e){
}
javax.swing.JFrame.setDefaultLookAndFeelDecorated(true);
new SFframe().setVisible(true);
지금 난 내 자신의 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>
코드를 내가
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);
버튼과 패널이 피부를 얻을 수 있지만, 물론, 윈도우/JFR 다음 LAF는 다음과 같습니다로드하는 데 사용 그렇지 않습니다.
Synth-XML을 사용하여 Window/JFrame을 스킨/장식하는 방법에 대한 정보를 찾지 못했습니다. 누군가 나를 도와 줄 수 있습니까?
+1 synth :-) – mKorbel