0

我想让pivot的bxml文件支持汉字,但是在应用程序运行的时候,没有显示汉字。bxml 中的编码是 utf-8。

这是我的例子:

FormTest.java:

public class FormTest extends Application.Adapter {
private Frame frame = null;

@Override
public void startup(Display display, Map<String, String> properties)
    throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    frame = new Frame((Component)bxmlSerializer.readObject(getClass()
    .getResource("form_test.bxml")));
    frame.setTitle("Form Test");
    frame.setPreferredSize(480, 360);
    frame.open(display);
}

@Override
public boolean shutdown(boolean optional) {
    if (frame != null) {
        frame.close();
    }

    return false;
}

public static void main(String[] args) {
    DesktopApplicationContext.main(FormTest.class, args);
}
}                      

form_test.bxml: 
<?xml version="1.0" encoding="UTF-8"?>
<Form styles="{fill:true, padding:0, leftAlignLabels:true}"
xmlns:bxml="http://pivot.apache.org/bxml"
xmlns:effects="org.apache.pivot.wtk.effects"
xmlns="org.apache.pivot.wtk">
<Form.Section heading="Test Section 1">
    <TextArea Form.label="Text Area" styles="{margin:0}"
        text="小人国的大王">
        <decorators>
            <effects:BaselineDecorator/>
        </decorators>
    </TextArea>
</Form.Section>
<Form.Section heading="Test Section 3">
    <Label Form.label="ABCD" text="小人国的巨人"
        styles="{wrapText:true}"/>
</Form.Section>
</Form>
4

0 回答 0