自定义外观JPogressBar&使用synth的JSplitPane xml

时间:2014-05-28 03:05:31

标签: java xml swing synth

我正在尝试使用使用synth的xml文件为我的程序创建自定义外观,并且它运行良好,但我不确定如何自定义JProgressBar或JSplitPane。我在JProgressBar上有一个没有问题的边框,但我找不到如何自定义加载动画。装载条设置为不确定。至于SplitPane,我唯一努力工作的就是拆分窗格拖动分隔符。拆分窗格在程序中正常工作,只需在拖动它时,分割线就不会显示。这是我当前的xml文件。谢谢你的帮助。

<?xml version="1.0" encoding="utf-8"?>
<synth>
<style id="frameStyle">
    <style id="backingStyle">
        <opaque value="TRUE" />
        <font name="Monaco" size="18" />
        <state>
            <color value="BLACK" type="BACKGROUND" />
            <color value="GRAY" type="FOREGROUND" />
        </state>
    </style>
    <bind style="backingStyle" type="region" key=".*" />
</style>


<style id="intputFieldStyle">
    <insets top="0" left="4" bottom="4" right="4" />
    <state>
        <font name="Verdana" size="14" />
        <color value="BLACK" type="BACKGROUND" />
        <color value="WHITE" type="FOREGROUND" />
    </state>
    <imagePainter method="textFieldBorder" path="laf/txtfld.png"
        sourceInsets="4 4 4 4" paintCenter="false" />
</style>


<style id="buttonStyle">
    <state>
        <font name="Monaco" size="12" />
        <color value="LIGHT_GRAY" type="FOREGROUND" />
        <imagePainter method="buttonBackground" path="laf/button_up.png"
            sourceInsets="4 3 3 4" paintCenter="false" />
    </state>
    <state value="PRESSED">
        <imagePainter method="buttonBackground" path="laf/button_down.png"
            sourceInsets="4 3 3 4" paintCenter="false" />
    </state>

    <state value="MOUSE_OVER">
        <imagePainter method="buttonBackground" path="laf/button_mouseover.png"
            sourceInsets="4 3 3 4" paintCenter="false" />
    </state>
</style>


<style id="userListStyle">
    <state>
        <font name="Monaco" size="12" />
        <color value="LIGHT_GRAY" type="BACKGROUND" />
        <color value="BLACK" type="FOREGROUND" />
    </state>
    <state value="SELECTED">
        <font name="Monaco" size="12" />
        <color value="MAGENTA" type="TEXT_BACKGROUND" />
        <color value="BLACK" type="TEXT_FOREGROUND" />
    </state>
</style>


<style id="labelStyle">
    <state>
        <color value="LIGHT_GRAY" type="FOREGROUND" />
    </state>
</style>


<style id="loadingBarStyle">
    <state>
        <color value="BLUE" type="BACKGROUND" />
        <color value="GREEN" type="FOREGROUND" />
        <imagePainter method="progressBarBorder" path="laf/loadingbar_outside.png"
            sourceInsets="6 6 6 6" paintCenter="false" />
    </state>
</style>


<style id="panelStyle">
    <state>
        <color value="DARK_GRAY" type="BACKGROUND" />
    </state>
</style>

<style id="splitPaneStyle">
    <state>
        <color value="WHITE" type="FOREGROUND"/>
    </state>
</style>

<bind style="frameStyle" type="region" key="Frame" />               <!-- Bind Frame -->
<bind style="intputFieldStyle" type="region" key="TextField" />     <!-- Bind textBox -->
<bind style="labelStyle" type="region" key="Label" />               <!-- Bind label -->
<bind style="loadingBarStyle" type="region" key="ProgressBar" />    <!-- Bind loadingbar -->
<bind style="buttonStyle" type="region" key="Button" />             <!-- Bind Login buttons -->
<bind style="userListStyle" type="region" key="List" />             <!-- Bind user list -->
<bind style="panelStyle" type="region" key="Panel" />               <!-- Bind Panel -->
<bind style="splitPaneStyle" type="region" key="SplitPane" />       <!-- Bind Split Pane -->

1 个答案:

答案 0 :(得分:1)

经过几个小时搜索Synth源代码后,我解决了这个问题。拆分的密钥为SplitPaneDivider,进度错误的密钥为ProgressBar。相应的方法是splitPaneDragDividerprogressBarForeground/Background